C12Adapter Opensource C++ Interface
|
Abstract synchronizer object. More...
Classes | |
class | Locker |
Scope based locker that acquires the lock at construction, and releases it at destruction. More... | |
Public Member Functions | |
void | Lock () |
Lock without timeout. More... | |
virtual void | Unlock ()=0 |
Unlock the synchronizer by a count of one. More... | |
bool | LockWithTimeout (long timeout) |
Static Public Member Functions | |
static void | WaitForAll (MSynchronizer *p0, MSynchronizer *p1, MSynchronizer *p2=0, MSynchronizer *p3=NULL, MSynchronizer *p4=NULL) |
Wait until all the objects in the list are set to nonsignaled state. More... | |
static bool | WaitWithTimeoutForAll (long timeout, MSynchronizer *p0, MSynchronizer *p1, MSynchronizer *p2=0, MSynchronizer *p3=NULL, MSynchronizer *p4=NULL) |
Wait until all the objects in the list are set to nonsignaled state, or timeout expires. More... | |
static unsigned | WaitForAny (MSynchronizer *p0, MSynchronizer *p1, MSynchronizer *p2=NULL, MSynchronizer *p3=NULL, MSynchronizer *p4=NULL) |
Wait until any of the objects in the list are set to nonsignaled state. More... | |
static bool | WaitWithTimeoutForAny (long timeout, unsigned *which, MSynchronizer *p0, MSynchronizer *p1, MSynchronizer *p2=0, MSynchronizer *p3=NULL, MSynchronizer *p4=NULL) |
Wait until any of the objects in the list are set to nonsignaled state, or timeout expires. More... | |
Protected Member Functions | |
MSynchronizer () | |
Constructor that creates synchronizer. More... | |
virtual | ~MSynchronizer () |
Destructor. | |
Abstract synchronizer object.
Synchronizers are event and semaphore. Critical section would also be a synchronizer, but due to internal details it is not derived from this class.
The implementation of the class is system dependent.
Use Locker subclass to handle the synchronizer in a way that guarantees the boundaries of the lock within the C++ scope whether or not an exception thrown.
|
inlineprotected |
Constructor that creates synchronizer.
As the class is abstract, the constructor is protected. Child classes have to initialize this class field m_handle in their constructors.
|
inline |
Lock without timeout.
Interpretation of this operation may vary depending on the child class.
bool MSynchronizer::LockWithTimeout | ( | long | timeout | ) |
Lock the synchronizer or timeout if the object is being locked for a specified number of milliseconds.
Interpretation of this operation may vary depending on the child class.
timeout | Timeout in milliseconds. Negative value means infinite timeout. Zero timeout can be used to know if the object is currently locked. Care should be taken when specifying very long timeouts, since the parameter is of type long, which is 32-bits long, about 25 days of milliseconds. |
|
pure virtual |
Unlock the synchronizer by a count of one.
Interpretation of this operation may vary depending on the child class.
Implemented in MEvent, and MSemaphore.
|
inlinestatic |
Wait until all the objects in the list are set to nonsignaled state.
Windows-only method.
Currently only up to five objects are supported. Only two synchronizers are mandatory. Once NULL is specified as object, no subsequent objects shall be supplied. There are assertions in the debug version. No timeout is provided, waiting is done infinitely.
p0 | First object, required. |
p1 | Second object, required. |
p2 | Third object, optional. |
p3 | Fourth object, optional. |
p4 | Fifth object, optional. |
|
inlinestatic |
Wait until any of the objects in the list are set to nonsignaled state.
Windows-only method.
Currently only up to five objects are supported. Only two synchronizers are mandatory. Once NULL is specified as object, no subsequent objects shall be supplied. There are assertions in the debug version. No timeout is provided, waiting is done infinitely.
p0 | First object, required. |
p1 | Second object, required. |
p2 | Third object, optional. |
p3 | Fourth object, optional. |
p4 | Fifth object, optional. |
|
inlinestatic |
Wait until all the objects in the list are set to nonsignaled state, or timeout expires.
Windows-only method.
Currently only up to five objects are supported. Only two synchronizers are mandatory. Once NULL is specified as object, no subsequent objects shall be supplied. There are assertions in the debug version.
timeout | Timeout in milliseconds. Negative value means infinite timeout. Zero timeout can be used to know if all objects are currently locked. Care should be taken when specifying very long timeouts, since the parameter is of type long, which is 32-bits, about 25 days of milliseconds. |
p0 | First object, required. |
p1 | Second object, required. |
p2 | Third object, optional. |
p3 | Fourth object, optional. |
p4 | Fifth object, optional. |
|
inlinestatic |
Wait until any of the objects in the list are set to nonsignaled state, or timeout expires.
Windows-only method.
Currently only up to five objects are supported. Only two synchronizers are mandatory. Once NULL is specified as object, no subsequent objects shall be supplied. There are assertions in the debug version.
timeout | Timeout in milliseconds. Negative value means infinite timeout. Zero timeout can be used to know if all objects are currently locked. Care should be taken when specifying very long timeouts, since the parameter is of type long, which is 32-bits, about 25 days of milliseconds. |
which | Return value through pointer, zero based index of the object that is in nonsignaled state. |
p0 | First object, required. |
p1 | Second object, required. |
p2 | Third object, optional. |
p3 | Fourth object, optional. |
p4 | Fifth object, optional. |