|
Zero
0.1.0
|
A short-term hold (exclusive or shared) on a page. More...
#include <latch.h>
Public Member Functions | |
| latch_t () | |
| Create a latch. More... | |
| ~latch_t () | |
| ostream & | print (ostream &) const |
| const void * | id () const |
| void | setname (const char *const desc) |
| Change the name of the latch. More... | |
| w_rc_t | latch_acquire (latch_mode_t m, int timeout=timeout_t::WAIT_FOREVER) |
| Acquire the latch in given mode. More... | |
| w_rc_t | upgrade_if_not_block (bool &would_block) |
| Upgrade from SH to EX if it can be done w/o blocking. More... | |
| void | downgrade () |
| Convert atomically an EX latch into an SH latch. More... | |
| int | latch_release () |
| release the latch. More... | |
| bool | is_latched () const |
| Unreliable, but helpful for some debugging. More... | |
| int | latch_cnt () const |
| Number of acquires. A thread may hold more than once. More... | |
| int | num_holders () const |
| How many threads hold the R/W lock. More... | |
| bool | is_mine () const |
| True iff held in EX mode. More... | |
| int | held_by_me () const |
| True iff held in EX or SH mode. Actually, it returns the. More... | |
| latch_mode_t | mode () const |
| EX, SH, or NL (if not held at all). More... | |
Static Public Member Functions | |
| static void | on_thread_destroy () |
| Destroy TLS structures. More... | |
Static Public Attributes | |
| static const char *const | latch_mode_str [4] = {"NL", "Q", "SH", "EX"} |
| string names of modes. More... | |
Private Member Functions | |
| w_rc_t | _acquire (latch_mode_t m, int timeout_in_ms, latch_holder_t *me) |
| int | _release (latch_holder_t *me) |
| void | _downgrade (latch_holder_t *me) |
| latch_t (const latch_t &) | |
| latch_t & | operator= (const latch_t &) |
Private Attributes | |
| srwlock_t | _lock |
| uint32_t | _total_count |
A short-term hold (exclusive or shared) on a page.
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.
| latch_t::latch_t | ( | ) |
Create a latch.
| latch_t::~latch_t | ( | ) |
|
private |
|
private |
|
private |
|
private |
| void latch_t::downgrade | ( | ) |
Convert atomically an EX latch into an SH latch.
Does not decrement the latch count.
| int latch_t::held_by_me | ( | ) | const |
True iff held in EX or SH mode. Actually, it returns the.
|
inline |
|
inline |
Unreliable, but helpful for some debugging.
| bool latch_t::is_mine | ( | ) | const |
True iff held in EX mode.
| w_rc_t latch_t::latch_acquire | ( | latch_mode_t | m, |
| int | timeout = timeout_t::WAIT_FOREVER |
||
| ) |
Acquire the latch in given mode.
|
inline |
Number of acquires. A thread may hold more than once.
| int latch_t::latch_release | ( | ) |
release the latch.
Decrements the latch count and releases only when it hits 0. Returns the resulting latch count.
|
inline |
EX, SH, or NL (if not held at all).
|
inline |
How many threads hold the R/W lock.
|
static |
Destroy TLS structures.
| std::ostream & latch_t::print | ( | std::ostream & | out | ) | const |
|
inline |
Change the name of the latch.
| 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.
|
mutableprivate |
|
private |
|
static |
string names of modes.
1.8.12