MySQL 8.0.39
Source Code Documentation
|
Represents the Binlog Group Commit Ticket - BGC Ticket. More...
#include <bgc_ticket.h>
Public Types | |
using | ValueType = std::uint64_t |
Public Member Functions | |
BgcTicket (const ValueType &ticket=first_ticket_value) | |
Constructor. More... | |
ValueType | get_value () const |
Obtain ticket value (1st bit cleared out) More... | |
const ValueType & | get () const |
Obtain ticket, may be in use or not (cannot be easily compared) More... | |
void | set_in_use () |
sets synchronization bit to 1, only 1 thread can operate on this ticket More... | |
void | set_used () |
sets synchronization bit to 0, other thread may "lock" this ticket for writing More... | |
bool | is_in_use () const |
checks whether this ticket is "locked" for writing More... | |
BgcTicket | next () const |
Returns incremented ticket, this remain unchanged. More... | |
void | set_next () |
Increments this ticket value. More... | |
bool | is_set () const |
Checks whether the ticket value differs from kTicketUnset. More... | |
Static Public Attributes | |
static constexpr BgcTicket::ValueType | kTicketUnset = 0 |
Default value of ticket, which means it is not being used. More... | |
static constexpr ValueType | set_bit = 1ULL << 63 |
64-bit mask with all 0s except for the most significant bit, to extract synchronization bit More... | |
static constexpr ValueType | clear_bit = set_bit - 1 |
64-bit mask with all 0s except for the most significant bit, to clear out synchronization bit - get ticket value More... | |
static constexpr ValueType | max_ticket_value |
Maximum allowed value for a ticket, after which will wrap around to first_ticket_value. More... | |
static constexpr ValueType | first_ticket_value = 1 |
Minimum allowed value for a ticket. More... | |
Protected Attributes | |
ValueType | m_ticket |
1 bit for synchronization, 63 bits - ticket value More... | |
Friends | |
class | AtomicBgcTicket |
bool | operator< (const BgcTicket &lhs, const BgcTicket &rhs) |
"Less than" operator More... | |
bool | operator> (const BgcTicket &lhs, const BgcTicket &rhs) |
"Greater than" operator More... | |
bool | operator>= (const BgcTicket &lhs, const BgcTicket &rhs) |
Comparison operator (>=) More... | |
bool | operator== (const BgcTicket &lhs, const BgcTicket &rhs) |
Comparison operator. More... | |
bool | operator!= (const BgcTicket &lhs, const BgcTicket &rhs) |
Comparison operator. More... | |
std::ostream & | operator<< (std::ostream &os, const BgcTicket &arg) |
Stream operator impl for BgcTicket class. More... | |
Represents the Binlog Group Commit Ticket - BGC Ticket.
Context: BGC ticket is granted to sessions with the same View, which may be changed with the View Change Event (server connecting to / disconnecting from group). When View Change Event is generated, it is granted a separate ticket value (value+1). All sessions that should be executed after View Change Event are assigned with a ticket value + 2. Implementation: Ticket is composed of 1 synchronization bit, used for critical section implementation and 63 bits that represent a ticket value. This class contains operation common for BGC tickets, such as: value extraction, changing synchronization bit between 0 and 1, ticket comparison, formatting, incrementation, internal constants. After reachning the maximum value for a ticket, ticket value is wrapped up to the first valid ticket value.
using binlog::BgcTicket::ValueType = std::uint64_t |
|
explicit |
Constructor.
[in] | ticket | Pattern to copy from |
|
inline |
Obtain ticket, may be in use or not (cannot be easily compared)
Cannot be easily compared, use comparison operator from BgcTicket instead
BgcTicket::ValueType binlog::BgcTicket::get_value | ( | ) | const |
Obtain ticket value (1st bit cleared out)
bool binlog::BgcTicket::is_in_use | ( | ) | const |
checks whether this ticket is "locked" for writing
true | Ticket is in use |
false | Ticket is not in use |
bool binlog::BgcTicket::is_set | ( | ) | const |
Checks whether the ticket value differs from kTicketUnset.
true | Ticket value is set |
false | Ticket value is unset |
BgcTicket binlog::BgcTicket::next | ( | ) | const |
Returns incremented ticket, this remain unchanged.
void binlog::BgcTicket::set_in_use | ( | ) |
sets synchronization bit to 1, only 1 thread can operate on this ticket
void binlog::BgcTicket::set_next | ( | ) |
Increments this ticket value.
void binlog::BgcTicket::set_used | ( | ) |
sets synchronization bit to 0, other thread may "lock" this ticket for writing
|
friend |
Comparison operator.
Comparison without (!) first bit
[in] | lhs | Left hand side BgcTicket argument (const ref) |
[in] | rhs | Right hand side BgcTicket argument (const ref) |
true | lhs != rhs |
false | rhs == lhs |
"Less than" operator
[in] | lhs | Left hand side BgcTicket argument (const ref) |
[in] | rhs | Right hand side BgcTicket argument (const ref) |
|
friend |
Stream operator impl for BgcTicket class.
[in] | os | Reference to stream obj |
[in] | arg | Constant reference to BgcTicket object |
Comparison operator.
Comparison without (!) first bit, meaning that if some thread locked on lhs or rhs, tickets can still be equal
[in] | lhs | Left hand side BgcTicket argument (const ref) |
[in] | rhs | Right hand side BgcTicket argument (const ref) |
true | lhs == rhs |
false | rhs != lhs |
"Greater than" operator
[in] | lhs | Left hand side BgcTicket argument (const ref) |
[in] | rhs | Right hand side BgcTicket argument (const ref) |
true | lhs > rhs |
false | rhs <= lhs |
Comparison operator (>=)
[in] | lhs | Left hand side BgcTicket argument (const ref) |
[in] | rhs | Right hand side BgcTicket argument (const ref) |
true | lhs >= rhs |
false | !(rhs >= lhs) |
64-bit mask with all 0s except for the most significant bit, to clear out synchronization bit - get ticket value
|
staticconstexpr |
Minimum allowed value for a ticket.
|
staticconstexpr |
Default value of ticket, which means it is not being used.
|
protected |
1 bit for synchronization, 63 bits - ticket value
|
staticconstexpr |
Maximum allowed value for a ticket, after which will wrap around to first_ticket_value.
|
staticconstexpr |
64-bit mask with all 0s except for the most significant bit, to extract synchronization bit