#include <lock.h>
Inherited by ActiveObject< message >, ActiveObject< ActiveAoTracker_msg_ * >, ActiveObject< ActiveDemoReceiver_msg_ * >, and ActiveObject< ActiveDemoSender_msg_ * >.
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 |
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
Definition at line 46 of file lock.h.
bool Lock::try_lock | ( | string | w | ) |
void Lock::unlock | ( | ) |
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.
Definition at line 55 of file lock.cpp.
bool Lock::deleted |
volatile void* Lock::locked |