PortMidi
Cross-platform MIDI IO library
pmutil.h File Reference

lock-free queue for building MIDI applications with PortMidi. More...

Go to the source code of this file.

Typedefs

typedef void PmQueue
 The queue representation is opaque. More...
 

Functions

PMEXPORT PmQueuePm_QueueCreate (long num_msgs, int32_t bytes_per_msg)
 create a single-reader, single-writer queue. More...
 
PMEXPORT PmError Pm_QueueDestroy (PmQueue *queue)
 destroy a queue and free its storage. More...
 
PMEXPORT PmError Pm_Dequeue (PmQueue *queue, void *msg)
 remove one message from the queue, copying it into msg. More...
 
PMEXPORT PmError Pm_Enqueue (PmQueue *queue, void *msg)
 insert one message into the queue, copying it from msg. More...
 
PMEXPORT int Pm_QueueFull (PmQueue *queue)
 test if the queue is full. More...
 
PMEXPORT int Pm_QueueEmpty (PmQueue *queue)
 test if the queue is empty. More...
 
PMEXPORT void * Pm_QueuePeek (PmQueue *queue)
 get a pointer to the item at the head of the queue. More...
 
PMEXPORT PmError Pm_SetOverflow (PmQueue *queue)
 allows the writer (enqueuer) to signal an overflow condition to the reader (dequeuer). More...
 

Detailed Description

lock-free queue for building MIDI applications with PortMidi.

PortMidi is not reentrant, and locks can suffer from priority inversion. To support coordination between system callbacks, a high-priority thread created with PortTime, and the main application thread, PortMidi uses a lock-free, non-blocking queue. The queue implementation is not particular to MIDI and is available for other uses.