[protected]
.
Inheritance diagram for w_pthread_lock_t:
This lock uses a Pthreads mutex for the lock.
This is not a true queue-based lock, since release doesn't inform the next node in the queue, and in fact the nodes aren't kept in a queue. It just gives pthread mutexes the same API as the other queue-based locks so that we use the same idioms for critical sections based on different kinds of locks.
The idiom for using these locks is that the qnode is on a threads's stack, so the qnode implicitly identifies the owning thread.
This allows us to add an is_mine() capability that otherwise the pthread mutexen don't have.
Finally, using this class ensures that the pthread_mutex_init/destroy is done.
See also: Synchronization Primitives
Definition at line 400 of file sthread.h.
Public Member Functions | |
w_pthread_lock_t () | |
~w_pthread_lock_t () | |
bool | attempt (ext_qnode *me) |
Returns true if success. | |
void * | acquire (ext_qnode *me) |
Acquire the lock and set the qnode to refer to this lock. | |
void | release (ext_qnode &me) |
Release the lock and clear the qnode. | |
void | release (ext_qnode_ptr me) |
Release the lock and clear the qnode. | |
bool | is_mine (ext_qnode *me) const |
Return true if this thread holds the lock. |
bool w_pthread_lock_t::is_mine | ( | ext_qnode * | me | ) | const [inline] |
Return true if this thread holds the lock.
This method doesn't actually check for this pthread holding the lock, but it checks that the qnode reference is to this lock. The idiom for using these locks is that the qnode is on a threads's stack, so the qnode implicitly identifies the owning thread.
Definition at line 491 of file sthread.h.
References w_assert1.
Referenced by acquire().
Here is the caller graph for this function: