Intel(R) Threading Building Blocks Doxygen Documentation
version 4.2.3
|
The scoped locking pattern. More...
#include <mutex.h>
Public Member Functions | |
scoped_lock () | |
Construct lock that has not acquired a mutex. More... | |
scoped_lock (mutex &mutex) | |
Acquire lock on given mutex. More... | |
~scoped_lock () | |
Release lock (if lock is held). More... | |
void | acquire (mutex &mutex) |
Acquire lock on given mutex. More... | |
bool | try_acquire (mutex &mutex) |
Try acquire lock on given mutex. More... | |
void | release () |
Release lock. More... | |
Private Member Functions | |
void __TBB_EXPORTED_METHOD | internal_acquire (mutex &m) |
All checks from acquire using mutex.state were moved here. More... | |
bool __TBB_EXPORTED_METHOD | internal_try_acquire (mutex &m) |
All checks from try_acquire using mutex.state were moved here. More... | |
void __TBB_EXPORTED_METHOD | internal_release () |
All checks from release using mutex.state were moved here. More... | |
![]() | |
no_copy () | |
Allow default construction. More... | |
Private Attributes | |
mutex * | my_mutex |
The pointer to the current mutex to work. More... | |
Friends | |
class | mutex |
The scoped locking pattern.
It helps to avoid the common problem of forgetting to release lock. It also nicely provides the "node" for queuing locks.
|
inline |
Construct lock that has not acquired a mutex.
Definition at line 78 of file mutex.h.
|
inline |
Acquire lock on given mutex.
Definition at line 81 of file mutex.h.
References acquire().
|
inline |
Release lock (if lock is held).
Definition at line 86 of file mutex.h.
References my_mutex, and release().
Acquire lock on given mutex.
Definition at line 92 of file mutex.h.
References internal_acquire(), tbb::mutex::lock(), mutex, and my_mutex.
Referenced by scoped_lock().
All checks from acquire using mutex.state were moved here.
Definition at line 31 of file mutex.cpp.
References __TBB_ASSERT, tbb::mutex::DESTROYED, tbb::internal::handle_perror(), tbb::mutex::HELD, tbb::mutex::impl, tbb::mutex::INITIALIZED, and my_mutex.
Referenced by acquire().
|
private |
All checks from release using mutex.state were moved here.
Definition at line 61 of file mutex.cpp.
References __TBB_ASSERT, __TBB_ASSERT_EX, tbb::mutex::DESTROYED, tbb::mutex::HELD, and tbb::mutex::INITIALIZED.
Referenced by release().
|
private |
All checks from try_acquire using mutex.state were moved here.
Definition at line 86 of file mutex.cpp.
References __TBB_ASSERT, tbb::mutex::DESTROYED, tbb::mutex::HELD, tbb::mutex::impl, and tbb::mutex::INITIALIZED.
Referenced by try_acquire().
|
inline |
Release lock.
Definition at line 114 of file mutex.h.
References internal_release(), my_mutex, and tbb::mutex::unlock().
Referenced by ~scoped_lock().
|
inline |
Try acquire lock on given mutex.
Definition at line 102 of file mutex.h.
References internal_try_acquire(), mutex, my_mutex, and tbb::mutex::try_lock().
|
friend |
Definition at line 136 of file mutex.h.
Referenced by acquire(), and try_acquire().
|
private |
The pointer to the current mutex to work.
Definition at line 125 of file mutex.h.
Referenced by acquire(), internal_acquire(), release(), try_acquire(), and ~scoped_lock().