C++ Based OPC UA Client/Server/PubSub SDK
1.7.9.586
|
Semaphore class is used to allow threads to synchronize access to a resource. More...
#include <uasemaphore.h>
Public Member Functions | |
UaSemaphore (OpcUa_UInt32 initalValue, OpcUa_UInt32 maxRange) | |
Construction Constructs a UaSemaphore object that allows threads to synchronize access to a resource. More... | |
~UaSemaphore () | |
Destruction Destroys the UaSemaphore object. | |
OpcUa_StatusCode | wait () |
Wait until the Semaphore is in signaled state. More... | |
OpcUa_StatusCode | timedWait (OpcUa_UInt32 msecTimeout) |
Wait until the Semaphore is in signaled state. More... | |
OpcUa_StatusCode | post (OpcUa_UInt32 releaseCount) |
Increases the count of the specified semaphore object by a specified amount. More... | |
Semaphore class is used to allow threads to synchronize access to a resource.
The UaSemaphore class provides a general counting semaphore. A semaphore is a generalization of a mutex. While a mutex can only be locked once, it's possible to acquire a semaphore multiple times. Semaphores are typically used to protect a certain number of identical resources. A typical application of semaphores is for controlling access to a circular buffer shared by a producer thread and a consumer thread. It is not possible to create shallow copies of this Class. It is not possible to use the default constructor.
UaSemaphore::UaSemaphore | ( | OpcUa_UInt32 | initalValue, |
OpcUa_UInt32 | maxRange | ||
) |
Construction Constructs a UaSemaphore object that allows threads to synchronize access to a resource.
initalValue | Specifies an initial count for the semaphore object. This value must be greater than or equal to zero and less than or equal to maxCount. The state of a semaphore is signaled when its count is greater than zero and non signaled when it is zero. |
maxRange | Specifies the maximum count for the semaphore object. This value must be greater than zero. |
OpcUa_StatusCode UaSemaphore::post | ( | OpcUa_UInt32 | releaseCount | ) |
Increases the count of the specified semaphore object by a specified amount.
releaseCount | Specifies the amount by which the current count of the semaphore object is to be increased. |
OpcUa_StatusCode UaSemaphore::timedWait | ( | OpcUa_UInt32 | msecTimeout | ) |
Wait until the Semaphore is in signaled state.
This function will block the current thread until the Semaphore is in signaled state or the passed timeout elapsed.
msecTimeout | Timeout in milliseconds. |
OpcUa_StatusCode UaSemaphore::wait | ( | ) |
Wait until the Semaphore is in signaled state.
This function will block the current thread until the Semaphore is in signaled state.