![]() |
Qore Programming Language Reference Manual 2.1.1
|
A class providing an implementation for a simple thread lock. More...
#include <QC_Mutex.dox.h>
Public Member Functions | |
| constructor () | |
| Creates the Mutex object. | |
| copy () | |
| Creates a new Mutex object, not based on the original. | |
| destructor () | |
| Destroys the object. | |
| nothing | lock () |
| Locks the Mutex object; blocks if the lock is already held. | |
| int | lock (timeout timeout_ms) |
| Locks the Mutex object; blocks if the lock is already held. | |
| 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. | |
| nothing | unlock () |
| Unlocks the Mutex object; wakes up one thread if any threads are blocked on this lock. | |
Public Member Functions inherited from Qore::Thread::AbstractSmartLock | |
| constructor () | |
| Throws an exception if called directly; this class can only be instantiated by builtin subclasses. | |
| string | getName () |
| Returns the name of the threading class directly inheriting this class. | |
| bool | lockOwner () |
| Returns True if the calling thread owns the lock, False if not. | |
| int | lockTID () |
| Returns the TID of the thread owning the lock or -1 if the lock is currently not acquired. | |
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 |