yep-coc

Crates.ioyep-coc
lib.rsyep-coc
version0.2.0
created_at2025-10-17 17:28:34.662205+00
updated_at2025-10-26 06:14:23.901187+00
descriptionYet another circular buffer. This one happens to be a zero copy, MPMC, lock free queue.
homepage
repositoryhttps://github.com/richkcho/yep-coc
max_upload_size
id1887960
size224,405
Richard Cho (richkcho)

documentation

README

yep-coc

Crates.io Documentation Rust

Overview

  • Multi-producer, multi-consumer lock-free queue built for zero-copy data paths.
  • Reserve/submit workflow lets producers publish buffers without blocking each other, while consumers reclaim slots independently.
  • Designed for high-performance IPC scenarios

Design Highlights

  • Queue metadata is stored separately from the contiguous data region so corruption in payload does not affect queue state.
  • Ownership of each slot is tracked with atomics, enabling concurrent producers and consumers without coarse locking.
  • Producers and consumers operate on YCQueueProduceSlot and YCQueueConsumeSlot handles, making it explicit when data is ready.
  • The API supports batching for reserve/submit/consume operations; single-slot helpers are layered on top for convenience.

Quick Start

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.

Commit count: 0

cargo fmt