CMSimpleQueue

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

Overview

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).

Topics

Creating Queues

CMSimpleQueueCreate

Creates a CMSimpleQueue.

Managing Queues

CMSimpleQueueEnqueue

Enqueues an element on the queue.

CMSimpleQueueDequeue

Dequeues an element from the queue.

CMSimpleQueueReset

Resets the queue.

Inspecting Queues

CMSimpleQueueGetHead

Returns the element at the head of the queue.

CMSimpleQueueGetCapacity

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

CMSimpleQueueGetCount

Returns the number of elements currently on the queue.

CMSimpleQueueGetFullness

A convenience macro that returns GetCount/GetCapacity, computed in floating point.

CMSimpleQueueGetTypeID

Returns the CFTypeID of CMSimpleQueue objects.

Data Types

CMSimpleQueueRef

A reference to a CMSimpleQueue, a Core Foundation object that implements a simple lockless queue of (void *) elements.

Constants

Simple Queue Error Codes

Error codes generated by CMSimpleQueue operations.

See Also

Queues

CMBufferQueue

A queue of timed buffers.

CMMemoryPool

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