Inherited by DD::Image::RecursiveLock, and DD::Image::SignalLock.
Public Member Functions | |
Lock () | |
pthread_mutex_t & | get_mutex () |
void | lock () |
void | spinlock () |
void | unlock () |
bool | trylock () |
void | spinsignal () |
void | spinwait () |
virtual | ~Lock () |
Protected Member Functions | |
Lock (const pthread_mutexattr_t *a) | |
Friends | |
class | SignalLock |
The Lock lets multiple threads synchronize the running of critial sections of code or the accessing of shared memory. The object acts as what the pthreads documentation calls a "mutex".
|
inline |
The constructor creates the lock unlocked.
|
inlinevirtual |
Destroys the lock. It does not matter if it is locked or not.
|
inline |
When this returns, the calling thread will "own" the lock.
If no thread owns the lock this will return immediately.
If another thread owns the lock this will block (not return) until that other thread calls unlock().
If this thread already owns the lock the result is undefined!!! To avoid this, use the class RecursiveLock.
Referenced by DD::Image::FileRead::closeFile(), DD::Image::Image_Cache::fileSize(), DD::Image::LUT::Linear(), DD::Image::FileReader::lock(), DD::Image::RecursiveLock::lock(), DD::Image::FileReader::read(), DD::Image::Image_Cache::remove(), DD::Image::Image_Cache::remove_oldest_files(), and DD::Image::FileReader::unlock().
|
inline |
This has the same result as lock(), but it works by spinning. This is faster than doing the system call but it keeps the processor busy looping this thread. You should use this call if and only if:
|
inline |
Release the lock. The calling thread must have called lock() once before this, or the results are undefined!
Referenced by DD::Image::FileRead::closeFile(), DD::Image::Image_Cache::fileSize(), DD::Image::LUT::Linear(), DD::Image::FileReader::lock(), DD::Image::FileReader::read(), DD::Image::Image_Cache::remove(), DD::Image::Image_Cache::remove_oldest_files(), DD::Image::FileReader::unlock(), and DD::Image::RecursiveLock::unlock().
©2024 The Foundry Visionmongers, Ltd. All Rights Reserved. |