#include <Standard_Mutex.hxx>
Inheritance diagram for Standard_Mutex:
Public Member Functions | |
Standard_EXPORT | Standard_Mutex () |
Constructor: creates a mutex object and initializes it. It is strongly recommended that mutexes were created as static objects whenever possible. | |
Standard_EXPORT | ~Standard_Mutex () |
Destructor: destroys the mutex object. | |
Standard_EXPORT void | Lock () |
Method to lock the mutex; waits until the mutex is released by other threads, locks it and then returns. | |
Standard_EXPORT Standard_Boolean | TryLock () |
Method to test the mutex; if the mutex is not hold by other thread, locks it and returns True; otherwise returns False without waiting mutex to be released. | |
Standard_EXPORT void | Unlock () |
Method to unlock the mutex; releases it to other users. | |
Private Member Functions | |
virtual void | DestroyCallback () |
Callback method to unlock the mutex if OCC exception or signal is raised. | |
Private Attributes | |
pthread_mutex_t | myMutex |
Data Structures | |
class | Sentry |
Simple sentry class providing convenient interface to mutex. More... | |
class | SentryNested |
Advanced Sentry class providing convenient interface to manipulate a mutex from one thread. More... |
Current implementation is very simple and straightforward; it is just a wrapper around POSIX pthread librray on UNIX/Linux, and CRITICAL_SECTIONs on Windows NT. It does not provide any advanced functionaly such as recursive calls to the same mutex from within one thread (such call will froze the execution).
Note that all the methods of that class are made inline, in order to keep maximal performance. This means that a library using the mutex might need to be linked to threads library directly.
The typical use of this class should be as follows:
Note that this class provides one feature specific to Open CASCADE: safe unlocking the mutex when signal is raised and converted to OCC exceptions (Note that with current implementation of this functionality on UNIX and Linux, C longjumps are used for that, thus destructors of classes are not called automatically).
To use this feature, call RegisterCallback() after Lock() or successful TryLock(), and UnregisterCallback() before Unlock() (or use Sentry classes).
|
|
|
|
|
Implements Standard_ErrorHandlerCallback. |
|
|
|
|
|
|
|
|