-
Notifications
You must be signed in to change notification settings - Fork 31
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
Waking the other side on async consumer / producer close #30
Changes from all commits
280ec30
87b91ba
de2b0a4
a7fad25
4aa2f34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
pub mod consumer; | ||
pub mod observer; | ||
pub mod producer; | ||
pub mod ring_buffer; | ||
|
||
pub use consumer::AsyncConsumer; | ||
pub use observer::AsyncObserver; | ||
pub use producer::AsyncProducer; | ||
|
||
pub trait AsyncRingBuffer: ringbuf::traits::RingBuffer + AsyncProducer + AsyncConsumer {} | ||
pub use ring_buffer::AsyncRingBuffer; | ||
|
||
pub use ringbuf::traits::*; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use crate::consumer::AsyncConsumer; | ||
use crate::producer::AsyncProducer; | ||
use ringbuf::traits::RingBuffer; | ||
|
||
pub trait AsyncRingBuffer: RingBuffer + AsyncProducer + AsyncConsumer { | ||
fn wake_producer(&self); | ||
fn wake_consumer(&self); | ||
} | ||
Comment on lines
+5
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add two methods for waking producer / consumer for trait AsyncRingBuffer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I doubt that such low-level controls should be exposed to user but I can't suggest a better way to do this yet. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Just realized it's interesting that Rust does not actually have private trait fn. |
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.
Must separate as two polling, otherwise waking the wrong party also passes this test.
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.
Good note,
join!
-ing multiple futures can actually lead to falsely passing this test because of spurious wake-ups.Also the usage of some async runtime (like Tokio or async-std) may be considered for testing. Each
async
block then can be ran in separate task.