-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
don't busy wait in SemaphoreGuard::acquire_arc #42
Conversation
tests/mutex.rs
Outdated
future::block_on(async { | ||
let m = Mutex::new(()); | ||
let _g = m.try_lock().unwrap(); | ||
assert!(future::poll_once(m.lock()).await.is_none()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test should also make sure that the future wakes back up once the other lock is dropped. Ditto for all of the others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it suffice to check that the future now returns Ready
or do you want to check that the Waker
was triggered? I can do the latter but I think I'd need to add waker-fn
as a dev dependency to do it cleanly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing both would be nice. It's fine to add waker-fn
as a dev dependency, since it's already brought in via futures-lite
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Fixes #41
I also added a test for this for each of
Mutex
/RwLock
/Semaphore
. The existing tests almost all use different threads when tasks contend for locks so they wouldn't catch this.