Atomic non-recursive waiting or non-waiting lock. More...
#include <lock.h>

Public Member Functions | |
| Lock () | |
| bool | try_lock (string w) |
| void | wait_lock (string w) |
| void | unlock () |
| virtual | ~Lock () |
Public Attributes | |
| volatile void * | locked |
| string | who |
| bool | deleted |
Atomic non-recursive waiting or non-waiting lock.
The lock class implements an atomic lock through a cmpxchg. It does not provide a counting lock. The main reason for this is that it forces the programmer to think about his locking system. If he needs to avoid locking the same object multiple times then the performance of the program in general improves. The lock will remember who currently obtained the lock through a string that must be passed when locking
| Lock::Lock | ( | ) | [inline] |
References deleted.
| virtual Lock::~Lock | ( | ) | [inline, virtual] |
References deleted.
| bool Lock::try_lock | ( | string | w | ) |
| void Lock::unlock | ( | ) |
Straightforwardly unlocks the lock.
References assert(), deleted, locked, and who.
Referenced by AutoLock::~AutoLock().
| void Lock::wait_lock | ( | string | w | ) |
Will lock the object, with a complete disregard who asks the lock. If the lock is asked by the same thread that has the lock then it will still be a deadlock. I believe this annoyance forces the programmer to think and improve his program. If wait is true then the call will try for 60s to acquire the lock. If that fails, it will assert itself. if wait is false, the lock return true or false depending on a successful acquisition.
References assert(), deleted, try_lock(), and who.
Referenced by AutoLock::AutoLock().
| bool Lock::deleted |
Referenced by Lock(), try_lock(), unlock(), wait_lock(), and ~Lock().
| volatile void* Lock::locked |
can be used as a boolean. NULL is unlocked, another value otherwise.
Referenced by try_lock(), and unlock().
| string Lock::who |
Referenced by try_lock(), unlock(), and wait_lock().
1.6.2