A simple, lockless FIFO queue of (void *
) elements.
Framework
- Core Media
Overview
CMSimple
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 CMSimple
can safely handle one enqueueing thread and one dequeueing thread. CMSimple
are lockless. As such, enqueues and/or dequeues can occur on the CoreAudio io
thread, where locking/blocking is forbidden.
The current status of a CMSimple
can be interrogated. Clients can get the current number of elements in the queue (CMSimple
Get
) as well as the maximum capacity of the queue (CMSimple
). There is also a convenience macro (CMSimple
Get
) that uses those two APIs to compute a Float32
between 0.0 and 1.0, representing the fullness of the queue. CMSimple
can be reset. This returns a newly created state, with no elements in the queue (but with the maximum capacity unchanged).