OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
ticket_machine/impl.hpp
Go to the documentation of this file.
1// Copyright (c) 2021 MIT Digital Currency Initiative,
2// Federal Reserve Bank of Boston
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#ifndef OPENCBDC_TX_SRC_PARSEC_TICKET_MACHINE_IMPL_H_
7#define OPENCBDC_TX_SRC_PARSEC_TICKET_MACHINE_IMPL_H_
8
9#include "interface.hpp"
11
12#include <atomic>
13#include <memory>
14
17 class impl : public interface {
18 public:
22 explicit impl(std::shared_ptr<logging::log> logger,
23 ticket_number_type range);
24
30 -> bool override;
31
32 private:
33 std::shared_ptr<logging::log> m_log;
34 std::atomic<ticket_number_type> m_next_ticket_number{};
35 ticket_number_type m_range;
36 };
37}
38
39#endif
Thread-safe ticket machine implementation.
impl(std::shared_ptr< logging::log > logger, ticket_number_type range)
Constructor.
auto get_ticket_number(get_ticket_number_callback_type result_callback) -> bool override
Returns a new range of ticket numbers via the provided callback function.
std::function< void(get_ticket_number_return_type)> get_ticket_number_callback_type
Callback function type for asynchronously handling ticket number requests.
uint64_t ticket_number_type
Type alias for a ticket number.