6#ifndef OPENCBDC_TX_SRC_NETWORK_PEER_H_ 
    7#define OPENCBDC_TX_SRC_NETWORK_PEER_H_ 
   26            = std::function<void(std::shared_ptr<cbdc::buffer>)>;
 
   38        peer(std::unique_ptr<tcp_socket> sock,
 
   40             bool attempt_reconnect);
 
   56        void send(
const std::shared_ptr<cbdc::buffer>& data);
 
   64        [[nodiscard]] 
auto connected() const -> 
bool;
 
   71        std::thread m_recv_thread;
 
   72        std::thread m_send_thread;
 
   74        std::thread m_reconnect_thread;
 
   75        std::mutex m_reconnect_mut;
 
   76        std::condition_variable m_reconnect_cv;
 
   77        bool m_reconnect{
false};
 
   78        bool m_attempt_reconnect{};
 
   80        std::atomic_bool m_running{
true};
 
   81        std::atomic_bool m_shut_down{
false};
 
   93        void signal_reconnect();
 
 
Thread-safe producer-consumer FIFO queue supporting multiple concurrent producers and consumers.
Buffer to store and retrieve byte data.
auto connected() const -> bool
Indicates whether the TCP socket is currently connected.
peer(std::unique_ptr< tcp_socket > sock, callback_type cb, bool attempt_reconnect)
Constructor.
std::function< void(std::shared_ptr< cbdc::buffer >)> callback_type
Type for the packet receipt callback function.
void send(const std::shared_ptr< cbdc::buffer > &data)
Sends buffered data.
void shutdown()
Clears any packets in the pending send queue.
~peer()
Destructor. Calls shutdown().
auto operator=(const peer &) -> peer &=delete
Wrapper for a TCP socket.