Qore Programming Language Reference Manual 1.18.1
|
A class providing an implementation for a simple thread lock. More...
#include <QC_Mutex.dox.h>
Public Member Methods | |
constructor () | |
Creates the Mutex object. More... | |
copy () | |
Creates a new Mutex object, not based on the original. More... | |
destructor () | |
Destroys the object. More... | |
nothing | lock () |
Locks the Mutex object; blocks if the lock is already held. More... | |
int | lock (timeout timeout_ms) |
Locks the Mutex object; blocks if the lock is already held. More... | |
int | trylock () |
Acquires the lock only if it is not already held; returns 0 for success (lock acquired) or -1 if the call would block. More... | |
nothing | unlock () |
Unlocks the Mutex object; wakes up one thread if any threads are blocked on this lock. More... | |
Public Member Methods inherited from Qore::Thread::AbstractSmartLock | |
constructor () | |
Throws an exception if called directly; this class can only be instantiated by builtin subclasses. More... | |
string | getName () |
Returns the name of the threading class directly inheriting this class. More... | |
bool | lockOwner () |
Returns True if the calling thread owns the lock, False if not. More... | |
int | lockTID () |
Returns the TID of the thread owning the lock or -1 if the lock is currently not acquired. More... | |
A class providing an implementation for a simple thread lock.
LOCK-ERROR
exception is thrown describing the situation.Qore::Thread::Mutex::constructor | ( | ) |
Creates the Mutex object.
Qore::Thread::Mutex::copy | ( | ) |
Creates a new Mutex object, not based on the original.
Qore::Thread::Mutex::destructor | ( | ) |
Destroys the object.
Note that it is a programming error to delete this object while other threads are blocked on it; in this case an exception is thrown in the deleting thread, and in each thread blocked on this object when it is deleted.
LOCK-ERROR | Object deleted while other threads blocked on it |
nothing Qore::Thread::Mutex::lock | ( | ) |
Locks the Mutex object; blocks if the lock is already held.
To release the Mutex, use Mutex::unlock()
LOCK-ERROR | lock called twice in the same thread, object deleted in another thread, etc |
THREAD-DEADLOCK | a deadlock was detected while trying to acquire the lock |
int Qore::Thread::Mutex::lock | ( | timeout | timeout_ms | ) |
Locks the Mutex object; blocks if the lock is already held.
An optional timeout value may be passed to this method, giving a time in milliseconds to wait for the lock to become free. Like all Qore functions and methods taking timeout values, a relative time value may be passed instead of an integer to make the timeout units clear
To release the Mutex, use Mutex::unlock()
timeout_ms | a timeout value to wait to acquire the lock; integers are interpreted as milliseconds; relative date/time values are interpreted literally (with a resolution of milliseconds) |
LOCK-ERROR | lock called twice in the same thread, object deleted in another thread, etc |
THREAD-DEADLOCK | a deadlock was detected while trying to acquire the lock |
int Qore::Thread::Mutex::trylock | ( | ) |
Acquires the lock only if it is not already held; returns 0 for success (lock acquired) or -1 if the call would block.
LOCK-ERROR | object deleted in another thread, etc |
THREAD-DEADLOCK | a deadlock was detected while trying to acquire the lock |
nothing Qore::Thread::Mutex::unlock | ( | ) |
Unlocks the Mutex object; wakes up one thread if any threads are blocked on this lock.
LOCK-ERROR | unlock called by a thread that does not own the lock or the lock is not locked, object deleted in another thread, etc |