tizpqueue

group tizpqueue

Non-synchronized priority queue. External synchronisation is required in case it needs to be accessed safely from multiple threads.

Typedefs

typedef struct tiz_pqueue tiz_pqueue_t

Priority queue opaque structure.

Functions

OMX_ERRORTYPE tiz_pqueue_init(tiz_pqueue_t ** app_pq, OMX_S32 a_max_prio, tiz_pq_cmp_f apf_cmp, tiz_soa_t * ap_soa, const char * ap_name)

Initialize a new empty priority queue with up to a_max_prio + 1 different priorities (i.e. priority groups [0..a_max_prio]). 0 is the highest priority.

A string of up to TIZ_PQUEUE_MAX_NAME_LEN characters that can be used during debugging to identify this queue

Parameters
  • app_pq: A handle to the priority queue object to be initialized
  • a_max_prio: Maximum number of priority groups that can be stored in the queue
  • apf_cmp: A comparison function (used by tiz_pqueue_remove and tiz_pqueue_removep functions)
  • ap_soa: The Tizonia’s small object allocator to allocate from. Or NULL if the Tizonia’s default allocation/deallocation routines should be used instead

Return
OMX_ErrorNone if success, OMX_ErrorInsufficientResources otherwise

void tiz_pqueue_destroy(tiz_pqueue_t * ap_pq)

Destroy a priority queue.

Pre
The queue must be empty before calling this function
Parameters
  • ap_pq: The priority queue to be destroyed. If NULL, or if the queue has already been detroyed, no operation is performed.

OMX_ERRORTYPE tiz_pqueue_send(tiz_pqueue_t * ap_pq, void * ap_data, OMX_S32 a_prio)

Add an item to the end of the priority group a_prio.

Return
OMX_ErrorNone if success, OMX_ErrorInsufficientResources otherwise

OMX_ERRORTYPE tiz_pqueue_receive(tiz_pqueue_t * ap_pq, void ** app_data)

Receive the first item from the queue. The item received is no longer in the queue.

Return
OMX_ErrorNone if success, OMX_ErrorNoMore if empty

OMX_ERRORTYPE tiz_pqueue_remove(tiz_pqueue_t * ap_pq, void * ap_data)

Remove an item from the queue. The item is found using the comparison function provided at initialization time (see tiz_pqueue_init).

Return
OMX_ErrorNone if success, OMX_ErrorNoMore if not found

OMX_ERRORTYPE tiz_pqueue_removep(tiz_pqueue_t * ap_pq, void * ap_data, OMX_S32 a_priority)

Remove an item from the queue. The item is found using the comparison function provided at initialization time (see tiz_pqueue_init). The search is restricted to the priority group a_priority.

Return
OMX_ErrorNone if success, OMX_ErrorNoMore if not found

OMX_S32 tiz_pqueue_remove_func(tiz_pqueue_t * ap_pq, tiz_pq_func_f apf_func, OMX_S32 a_data1, void * ap_data2)

Remove from the queue all the items found using the comparison function apf_func.

Return
The number of items removed from the queue.

OMX_ERRORTYPE tiz_pqueue_first(tiz_pqueue_t * ap_pq, void ** app_data)

Return a reference to the first item in the queue.

Return
OMX_ErrorNone if success, OMX_ErrorNoMore if none found

OMX_S32 tiz_pqueue_length(const tiz_pqueue_t * ap_pq)

Return the number of items currently in the queue.

Return
Number of items in the queue

OMX_S32 tiz_pqueue_dump(tiz_pqueue_t * ap_pq, tiz_pq_dump_item_f apf_dump)

This function dumps the contents of all the nodes in the queue using the apf_dump callback function.

Return
The number of nodes processed.