-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add feature "async" #68
base: main
Are you sure you want to change the base?
Conversation
But this is slow implementation
9ccfe09
to
d8016b2
Compare
Thanks for this PR! This is really interesting ... sadly I don't really have any experience with However, there might already be a problem: I'd like to not make the existing functionality any slower. But the Red is the I wouldn't actually expect a difference, maybe Apart from that, this is introducing locking (to the I don't really understand why to bother with atomic operations if a mutex is used anyway. But that might as well be my limited understanding of the topic, I'd like to learn more about it! Also, there seems to be really little code-reuse between sync and async parts, so is it a good idea to have both in the same codebase? Or would it be just as feasible to have separate sync and async crates? BTW, have you seen https://github.com/irrustible/async-spsc? |
I love this crate because this crate's get chunk with capacity & commit pattern is really useful for some scenario. I am trying on audio processing apps. This audio processing does
Many crates only features
So I didn't take async-mpsc.
I will add
I also want to be lock-free. I will make this PR as draft, and try to make it lock-free later.
Do you saying about
I want same codebase if can. |
- Reduce `Waker::clone` with `MutexReactor` - Port some function in `MutexReactor` to new trait `AsyncReactor`
Thanks, I'm glad you like it. This pattern doesn't seem to be very common, but I also like it (if I may say so myself).
OK, I'm looking forward to this. As I mentioned before, I'm not really familiar with I'm a bit concerned though that you are suggesting to add nearly as much code as there is already.
Not exactly. I was just wondering if you need atomic variables at all if you use a mutex. |
I found this pattern first time at System.IO.Pipelines(.NET). |
It is now almost wait-free. |
To make downstream crates can define generic function
That's great! I'm still struggling to understand how this whole thing works, but I'm glad to see that at least the Are there any guarantees about the And another thing I don't understand: the two |
No, I'm missing🙃 |
Are you talking about If you are talking about my code. you could see that there is no loop in |
Yes.
OK, I thought so. I was just wondering if the Rust language imposes any requirements on the
Maybe. It would still be good to know for sure.
Yes, that's a good idea, I should do that ...
No, I'm not.
Yes, that's good. But it is only wait-free if
Yes, I think that's fine.
TBH, I still don't really understand this, but it sounds good! |
Just for the record, I've found another async SPSC implementation: https://github.com/Liyixin95/spsc-rs |
CAS free!? It sounds like a magic. |
The creator of the ringbuf crate also seems to be working on an async SPSC ring buffer: https://github.com/agerasev/async-ringbuf |
Use
RingBuffer::<T>::new_async(usize)
to create ring buffer with async read write support.Use
write_chunk_uninit_async
,write_chunk_async
,read_chunk_async
to asynchronously wait for requested number of slots gets available.