S2OPC OPCUA Toolkit
Loading...
Searching...
No Matches
sopc_async_queue.h File Reference

An asynchronous and thread-safe queue implementation. More...

#include "sopc_enums.h"

Go to the source code of this file.

Typedefs

typedef struct SOPC_AsyncQueue SOPC_AsyncQueue
 

Functions

SOPC_ReturnStatus SOPC_AsyncQueue_Init (SOPC_AsyncQueue **queue, const char *queueName)
 Initialize the queue, the queue must be freed at the end of it's use with SOPC_AsyncQueue_Free.
 
SOPC_ReturnStatus SOPC_AsyncQueue_BlockingEnqueue (SOPC_AsyncQueue *queue, void *element)
 Add a new element (and allocate new queue element) to the head of the given linked queue. Can be used as FIFO queue with SOPC_AsyncQueue_BlokingDequeue or SOPC_AsyncQueue_NonBlockingDequeue.
 
SOPC_ReturnStatus SOPC_AsyncQueue_BlockingEnqueueFirstOut (SOPC_AsyncQueue *queue, void *element)
 Add a new element (and allocate new queue element) to the tail of the given linked queue. Can be used as LIFO queue with SOPC_AsyncQueue_BlokingDequeue or SOPC_AsyncQueue_NonBlockingDequeue.
 
SOPC_ReturnStatus SOPC_AsyncQueue_BlockingDequeue (SOPC_AsyncQueue *queue, void **element)
 Get and remove the head element of the queue. If the queue is empty the function will block until an element is added in the queue.
 
SOPC_ReturnStatus SOPC_AsyncQueue_NonBlockingDequeue (SOPC_AsyncQueue *queue, void **element)
 Get and remove the head element of the queue. If the queue is empty the function will block until an element is added in the queue. Element must be freed after used.
 
void SOPC_AsyncQueue_Free (SOPC_AsyncQueue **queue)
 : clear the queue by freeing every present element and free the asynchronous queue
 

Detailed Description

An asynchronous and thread-safe queue implementation.

Typedef Documentation

◆ SOPC_AsyncQueue

Function Documentation

◆ SOPC_AsyncQueue_Init()

SOPC_ReturnStatus SOPC_AsyncQueue_Init ( SOPC_AsyncQueue ** queue,
const char * queueName )

Initialize the queue, the queue must be freed at the end of it's use with SOPC_AsyncQueue_Free.

Parameters
queuePointer on the address of the queue
queueNamePointer on a string, useful to debug
Returns
SOPC_STATUS_OK if the queue is successfully initialized. SOPC_STATUS_OK or SOPC_STATUS_INVALID_PARAMETERS otherwise

◆ SOPC_AsyncQueue_BlockingEnqueue()

SOPC_ReturnStatus SOPC_AsyncQueue_BlockingEnqueue ( SOPC_AsyncQueue * queue,
void * element )

Add a new element (and allocate new queue element) to the head of the given linked queue. Can be used as FIFO queue with SOPC_AsyncQueue_BlokingDequeue or SOPC_AsyncQueue_NonBlockingDequeue.

Parameters
queuePointer on the linked queue in which new element must be added
elementPointer to the element to append, must be dynamically created by user.
Returns
SOPC_ReturnStatus value, if the element is successfully added SOPC_STATUS_OK, otherwise if queue or element is NULL SOPC_STATUS_INVALID_PARAMETERS, and SOPC_STATUS_NOK in others failed cases

◆ SOPC_AsyncQueue_BlockingEnqueueFirstOut()

SOPC_ReturnStatus SOPC_AsyncQueue_BlockingEnqueueFirstOut ( SOPC_AsyncQueue * queue,
void * element )

Add a new element (and allocate new queue element) to the tail of the given linked queue. Can be used as LIFO queue with SOPC_AsyncQueue_BlokingDequeue or SOPC_AsyncQueue_NonBlockingDequeue.

Parameters
queuePointer on the linked queue in which new element must be added
elementPointer to the element to append, must be dynamically created by user.
Returns
SOPC_ReturnStatus value, if the element is successfully added SOPC_STATUS_OK, otherwise if queue or element is NULL SOPC_STATUS_INVALID_PARAMETERS, and SOPC_STATUS_NOK in others failed cases

◆ SOPC_AsyncQueue_BlockingDequeue()

SOPC_ReturnStatus SOPC_AsyncQueue_BlockingDequeue ( SOPC_AsyncQueue * queue,
void ** element )

Get and remove the head element of the queue. If the queue is empty the function will block until an element is added in the queue.

Parameters
queuePointer on the linked queue in which the element will be removed
elementPointer to the address of the element to remove. element can be freed by caller after use
Returns
SOPC_ReturnStatus value, if the element is successfully removed SOPC_STATUS_OK, if queue or element is NULL SOPC_STATUS_INVALID_PARAMETERS

◆ SOPC_AsyncQueue_NonBlockingDequeue()

SOPC_ReturnStatus SOPC_AsyncQueue_NonBlockingDequeue ( SOPC_AsyncQueue * queue,
void ** element )

Get and remove the head element of the queue. If the queue is empty the function will block until an element is added in the queue. Element must be freed after used.

Parameters
queuePointer on the linked queue in which the element will be removed
elementPointer to the addres of the element to remove, element can be freed by caller after use
Returns
SOPC_ReturnStatus value, if the element is successfully removed SOPC_STATUS_OK, if queue or element is NULL SOPC_STATUS_INVALID_PARAMETERS, if no element in the queue SOPC_STATUS_WOULD_BLOCK

◆ SOPC_AsyncQueue_Free()

void SOPC_AsyncQueue_Free ( SOPC_AsyncQueue ** queue)

: clear the queue by freeing every present element and free the asynchronous queue