async-ringbuf
async/.await SPSC FIFO ring buffer.
Features
- Arbitrary item type (not only
Copy). - Items can be inserted and removed one by one or many at once.
- Thread-safe direct access to the internal ring buffer memory.
- Different types of buffers and underlying storages.
- Can be used without
stdand even withoutalloc. - Does not depends on any async runtime (like
tokioandasync-std).
Overview
This technically is the original ringbuf with an async synchronization.
AsyncProducer and AsyncConsumer traits provide async/await analogs of lock-free methods of Producer and Consumer with the ability to wait for certain event (such as appearance item or free slot, completing transfer of all items, or closing the opposite endpoint).
Examples
Simple
use ;
use ;
let rb = new;
let = rb.split;
const N_ITERS: i32 = 100;
join!;
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.