Crate cc_queue [] [src]


A CC Queue, which is:-

  • Non-blocking
  • Thread-safe
  • Concurrent
  • Unbounded
  • Faster than the MSQueue (Michael-Scott Queue, as used in Java)

And suitable for use with multiple memory allocators, including ones that use persistent memory.

To use it

  1. Create a new instance of CCQueue.
  2. Create a handle per-thread using CCQueue.new_per_thread_handle().
  3. Enqueue and dequeue

Notes on the API

The API may need to change to make it easier to manage the per-thread handle objects.



Allocators allow customization of the backing memory used by this queue. One use case is to be able to use persistent memory.



This is the cc queue object. It is safe to send references between threads. Each thread accessing the queue should call new_per_thread_handle. The queue supports being dropped and all Nodes being freed, however... It does not have any way to free the data owned by the nodes, so a memory leak is quite likely. Instead, it is better to call clear() with a callback which can free node data, which requires that there are no PerQueueThreadHandle in existence, even for the current thread. Rust's borrow checker should be able to enforce this.


This structure is allocated for each thread that wants to access a queue.