| Crates.io | yep-coc |
| lib.rs | yep-coc |
| version | 0.2.0 |
| created_at | 2025-10-17 17:28:34.662205+00 |
| updated_at | 2025-10-26 06:14:23.901187+00 |
| description | Yet another circular buffer. This one happens to be a zero copy, MPMC, lock free queue. |
| homepage | |
| repository | https://github.com/richkcho/yep-coc |
| max_upload_size | |
| id | 1887960 |
| size | 224,405 |
YCQueueProduceSlot and YCQueueConsumeSlot handles, making it explicit when data is ready.use yep_coc::queue_alloc_helpers::YCQueueOwnedData;
use yep_coc::{YCQueue, YCQueueSharedMeta};
fn main() {
// Allocate backing storage for 4 slots of 128 bytes each.
let mut owned = YCQueueOwnedData::new(4, 128);
let shared = YCQueueSharedMeta::new(&owned.meta);
let mut queue = YCQueue::new(shared, owned.data.as_mut_slice()).expect("queue");
// Producer: reserve a slot, write data, then publish it.
let mut produce_slot = queue.get_produce_slot().expect("produce slot");
produce_slot.data[..5].copy_from_slice(b"hello");
queue.mark_slot_produced(produce_slot).expect("publish");
// Consumer: take the slot, read the data, and return it to producers.
let consume_slot = queue.get_consume_slot().expect("consume slot");
assert_eq!(&consume_slot.data[..5], b"hello");
queue.mark_slot_consumed(consume_slot).expect("reclaim");
}
For more complete examples, check examples/simple-send-recv.rs and examples/multi-send-recv.rs.