|
The Pedigree Project
0.1
|
#include <UnlikelyLock.h>
Collaboration diagram for UnlikelyLock:Public Member Functions | |
| bool | enter () |
| void | leave () |
| bool | acquire () |
| void | release () |
Private Attributes | |
| Mutex | m_Lock |
| ConditionVariable | m_Condition |
| uint64_t | m_nReaders |
| bool | m_bActiveWriter |
An "Unlikely lock" is a lock which normally any number of threads can access concurrently, but when locked, all threads must exit and never reenter.
This is implemented as a simple counting semaphore that starts at zero. Any thread can acquire by adding one to the semaphore. If a thread discovers that the semaphore was over a threshold (100000), it decrements again and returns false.
Thus, the lock can be acquired by adding 100000 to the atomic member, and waiting until the atomic member's value drops to exactly 100000, at which point all threads will have exited.
Definition at line 46 of file UnlikelyLock.h.
| bool UnlikelyLock::acquire | ( | ) |
Locks the lock. Will not return until all other threads have exited the critical region.
Definition at line 53 of file UnlikelyLock.cc.
Referenced by PosixSubsystem::acquire(), PosixSubsystem::addFileDescriptor(), PosixSubsystem::allocateFd(), PosixSubsystem::copyDescriptors(), PosixSubsystem::freeFd(), PosixSubsystem::freeMultipleFds(), PosixSubsystem::getFd(), PosixSubsystem::PosixSubsystem(), and PosixSubsystem::setSignalHandler().
Here is the caller graph for this function:| bool UnlikelyLock::enter | ( | ) |
Enters the critical section.
Definition at line 32 of file UnlikelyLock.cc.
Referenced by PosixSubsystem::getFileDescriptor(), and PosixSubsystem::PosixSubsystem().
Here is the caller graph for this function:| void UnlikelyLock::leave | ( | ) |
Leaving the critical section.
Definition at line 44 of file UnlikelyLock.cc.
Referenced by PosixSubsystem::getFileDescriptor(), and PosixSubsystem::PosixSubsystem().
Here is the caller graph for this function:| void UnlikelyLock::release | ( | ) |
Releases the lock.
Definition at line 65 of file UnlikelyLock.cc.
Referenced by PosixSubsystem::addFileDescriptor(), PosixSubsystem::allocateFd(), PosixSubsystem::copyDescriptors(), PosixSubsystem::freeFd(), PosixSubsystem::freeMultipleFds(), PosixSubsystem::getFd(), PosixSubsystem::PosixSubsystem(), PosixSubsystem::release(), and PosixSubsystem::setSignalHandler().
Here is the caller graph for this function:
1.8.11