Collaboration diagram for latch_t:
A latch may be acquire()d multiple times by a single thread. The mode of subsequent acquire()s must be at or above the level of the currently held latch. Each of these individual locks must be released.
Definition at line 139 of file latch.h.
Public Member Functions | |
NORET | latch_t (const char *const desc=0) |
Create a latch with the given name. | |
NORET | ~latch_t () |
ostream & | print (ostream &) const |
const void * | id () const |
void | setname (const char *const desc) |
Change the name of the latch. | |
w_rc_t | latch_acquire (latch_mode_t m, sthread_t::timeout_in_ms timeout=sthread_base_t::WAIT_FOREVER) |
Acquire the latch in given mode. | |
w_rc_t | upgrade_if_not_block (bool &would_block) |
Upgrade from SH to EX if it can be done w/o blocking. | |
void | downgrade () |
Convert atomically an EX latch into an SH latch. | |
int | latch_release () |
release the latch. | |
bool | is_latched () const |
Unreliable, but helpful for some debugging. | |
int | latch_cnt () const |
Number of acquires. A thread may hold more than once. | |
int | num_holders () const |
How many threads hold the R/W lock. | |
bool | is_mine () const |
True iff held in EX mode. | |
int | held_by_me () const |
True iff held in EX or SH mode. Actually, it returns the. | |
latch_mode_t | mode () const |
EX, SH, or NL (if not held at all). | |
Static Public Attributes | |
static const char *const | latch_mode_str [3] = { "NL", "SH", "EX" } |
string names of modes. |
w_rc_t latch_t::latch_acquire | ( | latch_mode_t | m, | |
sthread_t::timeout_in_ms | timeout = sthread_base_t::WAIT_FOREVER | |||
) |
Acquire the latch in given mode.
Definition at line 348 of file latch.cpp.
References holder_search::value(), and w_assert1.
Here is the call graph for this function:
w_rc_t latch_t::upgrade_if_not_block | ( | bool & | would_block | ) |
Upgrade from SH to EX if it can be done w/o blocking.
Returns bool indicating if it would have blocked, in which case the upgrade did not occur. If it didn't have to block, the upgrade did occur.
Definition at line 356 of file latch.cpp.
References DBGTHRD, w_rc_t::err_num(), w_rc_t::is_error(), RC_AUGMENT, RCOK, holder_search::value(), and w_assert3.
Here is the call graph for this function:
void latch_t::downgrade | ( | ) |
Convert atomically an EX latch into an SH latch.
Does not decrement the latch count.
Definition at line 547 of file latch.cpp.
References holder_search::value(), and w_assert3.
Here is the call graph for this function:
int latch_t::latch_release | ( | ) |
release the latch.
Decrements the latch count and releases only when it hits 0. Returns the resulting latch count.
Definition at line 388 of file latch.cpp.
References holder_search::value(), and w_assert2.
Here is the call graph for this function: