16#include <boost/asio/io_context.hpp>
17#include <boost/asio/ip/tcp.hpp>
22#include <unordered_map>
35 class Router :
public std::enable_shared_from_this<Router> {
39 explicit Router(uint16_t port);
50 void AsyncRun(
size_t worker_threads);
76 std::unordered_map<Primary *, std::shared_ptr<std::promise<SessionInfo>>>
_promises;
A thread pool based on Boost.Asio's io context.
boost::asio::ip::tcp::endpoint GetLocalEndpoint() const
PrimaryCommands _commander
void Write(MultiGPUCommand id, Buffer &&buffer)
std::vector< std::shared_ptr< Primary > > _sessions
std::future< SessionInfo > WriteToNext(MultiGPUCommand id, Buffer &&buffer)
std::function< void(void)> _callback
std::unordered_map< Primary *, std::shared_ptr< std::promise< SessionInfo > > > _promises
std::shared_ptr< Listener > _listener
void ConnectSession(std::shared_ptr< Primary > session)
std::future< SessionInfo > WriteToOne(std::weak_ptr< Primary > server, MultiGPUCommand id, Buffer &&buffer)
boost::asio::ip::tcp::endpoint _endpoint
void DisconnectSession(std::shared_ptr< Primary > session)
bool HasClientsConnected()
void AsyncRun(size_t worker_threads)
void SetNewConnectionCallback(std::function< void(void)>)
std::weak_ptr< Primary > GetNextServer()
PrimaryCommands & GetCommander()
This file contains definitions of common data structures used in traffic manager.
std::shared_ptr< Primary > session