High Performance OPC UA Server SDK  1.1.0.158
semaphore

Semaphore for managing shared resources. More...

Functions

int ua_sem_create (ua_sem_t *sem, int shared, unsigned int value, const char *name)
 Initialize a semaphore. More...
 
int ua_sem_destroy (ua_sem_t *sem)
 Clear a semaphore. More...
 
int ua_sem_post (ua_sem_t *sem)
 Post (increment/unlock) a semaphore. More...
 
int ua_sem_wait (ua_sem_t *sem)
 Decrement/lock a semaphore. More...
 
int ua_sem_trywait (ua_sem_t *sem)
 Decrement/lock a semaphore. More...
 
int ua_sem_timedwait (ua_sem_t *sem, int ms_timeout)
 Decrement/lock a semaphore. More...
 

Detailed Description

Semaphore for managing shared resources.

Function Documentation

int ua_sem_create ( ua_sem_t sem,
int  shared,
unsigned int  value,
const char *  name 
)

Initialize a semaphore.

Parameters
semSemaphore to initialize.
shared1 if the semaphore should be shared.
valueInitial value of the semaphore.
nameUnique name for the semaphore
Returns
Zero on success or errorcode on failure.
int ua_sem_destroy ( ua_sem_t sem)

Clear a semaphore.

The semaphore shall no longer be used.

Parameters
semSemaphore to clear.
Returns
Zero on success or errorcode on failure.
int ua_sem_post ( ua_sem_t sem)

Post (increment/unlock) a semaphore.

Parameters
semSemaphore to post.
Returns
Zero on success or errorcode on failure.
int ua_sem_timedwait ( ua_sem_t sem,
int  ms_timeout 
)

Decrement/lock a semaphore.

If the value of the semaphore is zero the function waits (blocks) for the given timeout. If the value could not be decremented in the given time the errorcode UA_EBADOPTIMEOUT is returned.

Parameters
semSemaphore to decrement.
timeoutTime in milliseconds to wait.
Returns
Zero on success or errorcode on failure.
int ua_sem_trywait ( ua_sem_t sem)

Decrement/lock a semaphore.

If the value of the semaphore is zero the function returns with the errorcode UA_EBADAGAIN instead of waiting.

Parameters
semSemaphore to decrement.
Returns
Zero on success or errorcode on failure.
int ua_sem_wait ( ua_sem_t sem)

Decrement/lock a semaphore.

If the value of the semaphore is zero the function waits (blocks) until the value becomes greater than zero.

Parameters
semSemaphore to decrement/wait.
Returns
Zero on success or errorcode on failure.