20#include <boost/asio/io_context.hpp>
22#include <boost/asio/ip/tcp.hpp>
30#include <unordered_map>
49 class Router :
public std::enable_shared_from_this<Router> {
53 explicit Router(uint16_t port);
56 void Write(MultiGPUCommand
id, Buffer &&buffer);
57 std::future<SessionInfo>
WriteToNext(MultiGPUCommand
id, Buffer &&buffer);
58 std::future<SessionInfo>
WriteToOne(std::weak_ptr<Primary> server, MultiGPUCommand
id, Buffer &&buffer);
64 void AsyncRun(
size_t worker_threads);
90 std::unordered_map<Primary *, std::shared_ptr<std::promise<SessionInfo>>>
_promises;
包含 Carla 框架中与网络流相关的类和函数的声明。
std::unordered_map< Primary *, std::shared_ptr< std::promise< SessionInfo > > > _promises
void Write(MultiGPUCommand id, Buffer &&buffer)
void AsyncRun(size_t worker_threads)
boost::asio::ip::tcp::endpoint _endpoint
bool HasClientsConnected()
boost::asio::ip::tcp::endpoint GetLocalEndpoint() const
PrimaryCommands _commander
std::function< void(void)> _callback
void DisconnectSession(std::shared_ptr< Primary > session)
std::future< SessionInfo > WriteToOne(std::weak_ptr< Primary > server, MultiGPUCommand id, Buffer &&buffer)
std::shared_ptr< Listener > _listener
void ConnectSession(std::shared_ptr< Primary > session)
std::vector< std::shared_ptr< Primary > > _sessions
PrimaryCommands & GetCommander()
std::future< SessionInfo > WriteToNext(MultiGPUCommand id, Buffer &&buffer)
void SetNewConnectionCallback(std::function< void(void)>)
std::weak_ptr< Primary > GetNextServer()
一块原始数据。 请注意,如果需要更多容量,则会分配一个新的内存块,并 删除旧的内存块。这意味着默认情况下,缓冲区只能增长。要释放内存,使用 clear 或 pop。
std::shared_ptr< Primary > session
std::shared_ptr< Primary > session