VTK
9.4.20250409
|
mutual exclusion locking class using atomic operations More...
#include <vtkAtomicMutex.h>
Public Member Functions | |
vtkAtomicMutex () | |
~vtkAtomicMutex ()=default | |
vtkAtomicMutex (const vtkAtomicMutex &other) | |
vtkAtomicMutex & | operator= (const vtkAtomicMutex &other) |
void | lock () |
Lock/Unlock atomic operation. | |
void | unlock () |
Lock/Unlock atomic operation. | |
mutual exclusion locking class using atomic operations
vtkAtomicMutex allows the locking of variables which are accessed through different threads using atomic operations. An atomic mutex might be preferable over std::mutex, because it is faster when you want to spin lock and the probability of acquiring the lock is high. The benefit of vtkAtomicMutex over std::atomic<bool> is that it is copy constructible, and that is has predefined optimized lock/unlock functions that can be used as a drop in replacement instead of std::mutex.
Definition at line 23 of file vtkAtomicMutex.h.
vtkAtomicMutex::vtkAtomicMutex | ( | ) |
|
default |
vtkAtomicMutex::vtkAtomicMutex | ( | const vtkAtomicMutex & | other | ) |
vtkAtomicMutex & vtkAtomicMutex::operator= | ( | const vtkAtomicMutex & | other | ) |
void vtkAtomicMutex::lock | ( | ) |
Lock/Unlock atomic operation.
Note: lock/unlock is lowercase, to conform to the mutex wrapper std::lock_guard which provides a convenient RAII-style mechanism for owning a mutex for the duration of a scoped block.
void vtkAtomicMutex::unlock | ( | ) |
Lock/Unlock atomic operation.
Note: lock/unlock is lowercase, to conform to the mutex wrapper std::lock_guard which provides a convenient RAII-style mechanism for owning a mutex for the duration of a scoped block.