19#include <boost/asio/io_context.hpp>
20#include <boost/asio/ip/tcp.hpp>
21#include <boost/asio/steady_timer.hpp>
22#include <boost/asio/strand.hpp>
38 :
public std::enable_shared_from_this<Secondary>,
43 using endpoint = boost::asio::ip::tcp::endpoint;
56 void AsyncRun(
size_t worker_threads);
58 void Write(std::shared_ptr<const carla::streaming::detail::tcp::Message> message);
60 void Write(std::string text);
73 template <
typename... Buffers>
77 "This function only accepts arguments of type BufferView.");
78 return std::make_shared<const carla::streaming::detail::tcp::Message>(buffers...);
83 using message_type = std::shared_ptr<const carla::streaming::detail::tcp::Message>;
Inherit (privately) to suppress copy/move construction and assignment.
A thread pool based on Boost.Asio's io context.
std::function< void(MultiGPUCommand, carla::Buffer)> callback_type
void Disconnect()
Marks the connection lost and closes the socket. Strand only.
boost::asio::ip::tcp::endpoint _endpoint
boost::asio::ip::tcp::endpoint endpoint
std::shared_ptr< BufferPool > _buffer_pool
std::shared_ptr< const carla::streaming::detail::tcp::Message > message_type
void WriteNext()
Starts writing the front of the write queue. Strand only.
boost::asio::io_context::strand _strand
SecondaryCommands _commander
std::deque< message_type > _write_queue
Strand only: messages waiting to be written, oldest first, with a single write in flight so that two ...
uint64_t _write_generation
Strand only: bumped by Disconnect(), so that the completion of a write it dropped leaves the queue al...
std::atomic_bool _connected
boost::asio::ip::tcp::socket _socket
bool IsConnected() const
Whether the connection to the primary is up: false before the first connect, after a read fails (the ...
void Stop()
Blocks until the io threads have exited.
SecondaryCommands & GetCommander()
boost::asio::steady_timer _connection_timer
void AsyncRun(size_t worker_threads)
static auto MakeMessage(Buffers... buffers)
void Write(std::shared_ptr< const carla::streaming::detail::tcp::Message > message)
endpoint::protocol_type protocol_type
This file contains definitions of common data structures used in traffic manager.
std::shared_ptr< BufferView > SharedBufferView