A simple, lockless FIFO queue of (void *) elements.


CMSimpleQueues are Core Foundation-based objects that implement a simple lockless FIFO queue of (void *) elements. The elements are not assumed to be pointers; they could be simple pointer-sized numeric values (although NULL or 0-valued elements are not allowed). If the elements are in fact pointers to allocated memory buffers, buffer lifetime management must be handled externally.

A CMSimpleQueue can safely handle one enqueueing thread and one dequeueing thread. CMSimpleQueues are lockless. As such, enqueues and/or dequeues can occur on the CoreAudio ioProc thread, where locking/blocking is forbidden.

The current status of a CMSimpleQueue can be interrogated. Clients can get the current number of elements in the queue (CMSimpleQueueGetCount) as well as the maximum capacity of the queue (CMSimpleQueueGetCapacity). There is also a convenience macro (CMSimpleQueueGetFullness) that uses those two APIs to compute a Float32 between 0.0 and 1.0, representing the fullness of the queue. CMSimpleQueues can be reset. This returns a newly created state, with no elements in the queue (but with the maximum capacity unchanged).


Inspecting Queues

func CMSimpleQueueGetHead(CMSimpleQueue) -> UnsafeRawPointer?

Returns the element at the head of the queue.

func CMSimpleQueueGetCapacity(CMSimpleQueue) -> Int32

Returns the number of elements that can be held in the queue.

func CMSimpleQueueGetCount(CMSimpleQueue) -> Int32

Returns the number of elements currently on the queue.

func CMSimpleQueueGetTypeID() -> CFTypeID

Returns the CFTypeID of CMSimpleQueue objects.


Simple Queue Error Codes

Error codes generated by CMSimpleQueue operations.

See Also



A queue of timed buffers.


A pool used for optimizing memory allocation when large blocks of memory must be repeatedly allocated, deallocated, and then reallocated.