![]() |
Open CASCADE Technology Reference Manual 8.0.0
|
#include <Standard_Integer.hxx>#include <Standard_Boolean.hxx>#include <Standard_ErrorHandler.hxx>#include <Standard_Macro.hxx>#include <NCollection_Shared.hxx>#include <pthread.h>#include <unistd.h>#include <time.h>Functions | |
| Sentry (Standard_Mutex *theMutex) | |
| Constructor - initializes the sentry object by pointer to a mutex and locks the mutex if its pointer is not NULL. | |
| ~Sentry () | |
| Destructor - unlocks the mutex if already locked. | |
| ~Standard_Mutex () override | |
| Destructor: destroys the mutex object. | |
| bool | 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. | |
Variables | |
| class Standard_Mutex is | deprecated |
| Mutex: a class to synchronize access to shared data. | |
| use std::mutex instead Will be removed in OCCT | Standard_Mutex () |
| Constructor: creates a mutex object and initializes it. It is strongly recommended that mutexes were created as static objects whenever possible. | |
| Sentry | ( | Standard_Mutex * | theMutex | ) |
Constructor - initializes the sentry object by pointer to a mutex and locks the mutex if its pointer is not NULL.
| bool 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.
| ~Sentry | ( | ) |
Destructor - unlocks the mutex if already locked.
|
override |
Destructor: destroys the mutex object.
| class Standard_Mutex is deprecated |
Mutex: a class to synchronize access to shared data.
This is simple encapsulation of tools provided by the operating system to synchronize access to shared data from threads within one process.
Current implementation is very simple and straightforward; it is just a wrapper around POSIX pthread library on UNIX/Linux, and CRITICAL_SECTIONs on Windows NT. It does not provide any advanced functionality such as recursive calls to the same mutex from within one thread (such call will freeze 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).
| Standard_Mutex |
Constructor: creates a mutex object and initializes it. It is strongly recommended that mutexes were created as static objects whenever possible.