24#ifndef BINLOG_BCG_TICKET_H
25#define BINLOG_BCG_TICKET_H
151 std::numeric_limits<ValueType>::max() &
clear_bit;
Implements atomic ops on BgcTicket object.
Definition: atomic_bgc_ticket.h:43
Represents the Binlog Group Commit Ticket - BGC Ticket.
Definition: bgc_ticket.h:54
friend bool operator<(const BgcTicket &lhs, const BgcTicket &rhs)
"Less than" operator
Definition: bgc_ticket.cc:57
static constexpr ValueType first_ticket_value
Minimum allowed value for a ticket.
Definition: bgc_ticket.h:153
static constexpr ValueType max_ticket_value
Maximum allowed value for a ticket, after which will wrap around to first_ticket_value.
Definition: bgc_ticket.h:150
BgcTicket(const ValueType &ticket=first_ticket_value)
Constructor.
Definition: bgc_ticket.cc:29
void set_next()
Increments this ticket value.
Definition: bgc_ticket.cc:55
friend bool operator!=(const BgcTicket &lhs, const BgcTicket &rhs)
Comparison operator.
Definition: bgc_ticket.cc:73
void set_used()
sets synchronization bit to 0, other thread may "lock" this ticket for writing
Definition: bgc_ticket.cc:39
const ValueType & get() const
Obtain ticket, may be in use or not (cannot be easily compared)
Definition: bgc_ticket.h:110
std::uint64_t ValueType
Definition: bgc_ticket.h:56
bool is_in_use() const
checks whether this ticket is "locked" for writing
Definition: bgc_ticket.cc:40
friend bool operator>=(const BgcTicket &lhs, const BgcTicket &rhs)
Comparison operator (>=)
Definition: bgc_ticket.cc:64
ValueType get_value() const
Obtain ticket value (1st bit cleared out)
Definition: bgc_ticket.cc:35
friend bool operator==(const BgcTicket &lhs, const BgcTicket &rhs)
Comparison operator.
Definition: bgc_ticket.cc:68
ValueType m_ticket
1 bit for synchronization, 63 bits - ticket value
Definition: bgc_ticket.h:156
friend bool operator>(const BgcTicket &lhs, const BgcTicket &rhs)
"Greater than" operator
Definition: bgc_ticket.cc:62
static constexpr ValueType set_bit
64-bit mask with all 0s except for the most significant bit, to extract synchronization bit
Definition: bgc_ticket.h:144
friend std::ostream & operator<<(std::ostream &os, const BgcTicket &arg)
Stream operator impl for BgcTicket class.
Definition: bgc_ticket.cc:50
BgcTicket next() const
Returns incremented ticket, this remain unchanged.
Definition: bgc_ticket.cc:42
bool is_set() const
Checks whether the ticket value differs from kTicketUnset.
Definition: bgc_ticket.cc:31
static constexpr ValueType clear_bit
64-bit mask with all 0s except for the most significant bit, to clear out synchronization bit - get t...
Definition: bgc_ticket.h:147
void set_in_use()
sets synchronization bit to 1, only 1 thread can operate on this ticket
Definition: bgc_ticket.cc:38
static constexpr BgcTicket::ValueType kTicketUnset
Default value of ticket, which means it is not being used.
Definition: bgc_ticket.h:59