14 std::unique_lock l(m_mut);
15 m_tickets.emplace(ticket_number,
17 std::move(state_update),
28 std::unique_lock l(m_mut);
29 auto it = m_tickets.find(ticket_number);
30 if(it == m_tickets.end()) {
35 for(
auto&& [k, v] : t.m_state_update) {
36 m_state[k] = std::move(v);
47 std::unique_lock l(m_mut);
48 m_tickets.erase(ticket_number);
58 std::unique_lock l(m_mut);
61 result_callback(std::move(ret));
66 std::unique_lock l(m_mut);
std::function< void(get_tickets_return_type)> get_tickets_callback_type
Callback function type for the result of a get tickets operation.
std::variant< tickets_type, error_code > get_tickets_return_type
Return type from a get tickets operation.
std::function< void(return_type)> callback_type
Callback function type for the result of a prepare operation.
std::unordered_map< key_type, value_type, hashing::const_sip_hash< key_type > > state_type
Type for state updates to a shard.
std::optional< error_code > return_type
Return type from a prepare operation. An error, if applicable.
auto get_tickets(get_tickets_callback_type result_callback) const -> bool override
Retrieves unfinished tickets from the state machine.
auto get_state() const -> state_type
Return the keys and values stored by the shard.
auto prepare(ticket_number_type ticket_number, broker_id_type broker_id, state_type state_update, callback_type result_callback) -> bool override
Stores a prepare request for a ticket in the state machine.
auto commit(ticket_number_type ticket_number, callback_type result_callback) -> bool override
Stores a commit request in the state machine.
auto finish(ticket_number_type ticket_number, callback_type result_callback) -> bool override
Stores a finish request in the state machine.
parsec::ticket_machine::ticket_number_type ticket_number_type
Type for a ticket number.
size_t broker_id_type
Type for the ID of a broker.
@ unknown_ticket
The given ticket number is not known to this shard.
@ prepared
Prepared, holds locks.
@ committed
Committed, not holding any locks.
Ticket date stored in the replicated state machine.