#include <router.h>
Public Member Functions | |
void | AsyncRun (size_t worker_threads) |
PrimaryCommands & | GetCommander () |
boost::asio::ip::tcp::endpoint | GetLocalEndpoint () const |
std::weak_ptr< Primary > | GetNextServer () |
bool | HasClientsConnected () |
Router (void) | |
Router (uint16_t port) | |
void | SetCallbacks () |
void | SetNewConnectionCallback (std::function< void(void)>) |
void | Stop () |
void | Write (MultiGPUCommand id, Buffer &&buffer) |
std::future< SessionInfo > | WriteToNext (MultiGPUCommand id, Buffer &&buffer) |
std::future< SessionInfo > | WriteToOne (std::weak_ptr< Primary > server, MultiGPUCommand id, Buffer &&buffer) |
~Router () | |
Private Member Functions | |
void | ClearSessions () |
void | ConnectSession (std::shared_ptr< Primary > session) |
void | DisconnectSession (std::shared_ptr< Primary > session) |
Private Attributes | |
std::function< void(void)> | _callback |
PrimaryCommands | _commander |
boost::asio::ip::tcp::endpoint | _endpoint |
std::shared_ptr< Listener > | _listener |
std::mutex | _mutex |
uint32_t | _next |
ThreadPool | _pool |
std::unordered_map< Primary *, std::shared_ptr< std::promise< SessionInfo > > > | _promises |
std::vector< std::shared_ptr< Primary > > | _sessions |
carla::multigpu::Router::Router | ( | void | ) |
Definition at line 15 of file router.cpp.
|
explicit |
Definition at line 29 of file router.cpp.
References _endpoint, _listener, _pool, and carla::ThreadPool::io_context().
carla::multigpu::Router::~Router | ( | ) |
Definition at line 18 of file router.cpp.
References Stop().
void carla::multigpu::Router::AsyncRun | ( | size_t | worker_threads | ) |
Definition at line 78 of file router.cpp.
References _pool, and carla::ThreadPool::AsyncRun().
|
private |
Definition at line 106 of file router.cpp.
References _mutex, _sessions, and carla::log_info().
Referenced by Stop().
|
private |
Definition at line 86 of file router.cpp.
References _callback, _mutex, _sessions, DEBUG_ASSERT, and carla::log_info().
|
private |
Definition at line 96 of file router.cpp.
References _mutex, _sessions, DEBUG_ASSERT, and carla::log_info().
|
inline |
Definition at line 58 of file router.h.
References carla::multigpu::SessionInfo::session.
boost::asio::ip::tcp::endpoint carla::multigpu::Router::GetLocalEndpoint | ( | ) | const |
Definition at line 82 of file router.cpp.
References _endpoint.
std::weak_ptr< Primary > carla::multigpu::Router::GetNextServer | ( | ) |
Definition at line 188 of file router.cpp.
|
inline |
void carla::multigpu::Router::SetCallbacks | ( | ) |
Definition at line 36 of file router.cpp.
References _commander, _endpoint, _listener, _promises, carla::log_info(), and carla::multigpu::PrimaryCommands::set_router().
void carla::multigpu::Router::SetNewConnectionCallback | ( | std::function< void(void)> | func | ) |
Definition at line 73 of file router.cpp.
References _callback.
void carla::multigpu::Router::Stop | ( | void | ) |
Definition at line 22 of file router.cpp.
References _listener, _pool, ClearSessions(), and carla::ThreadPool::Stop().
Referenced by ~Router().
void carla::multigpu::Router::Write | ( | MultiGPUCommand | id, |
Buffer && | buffer | ||
) |
Definition at line 112 of file router.cpp.
References _mutex, _sessions, carla::BufferView::CreateFrom(), carla::multigpu::CommandHeader::id, carla::multigpu::Primary::MakeMessage(), and carla::multigpu::CommandHeader::size.
std::future< SessionInfo > carla::multigpu::Router::WriteToNext | ( | MultiGPUCommand | id, |
Buffer && | buffer | ||
) |
Definition at line 132 of file router.cpp.
References _mutex, _next, _promises, _sessions, carla::BufferView::CreateFrom(), carla::multigpu::CommandHeader::id, carla::multigpu::Primary::MakeMessage(), and carla::multigpu::CommandHeader::size.
std::future< SessionInfo > carla::multigpu::Router::WriteToOne | ( | std::weak_ptr< Primary > | server, |
MultiGPUCommand | id, | ||
Buffer && | buffer | ||
) |
Definition at line 164 of file router.cpp.
References _mutex, _promises, carla::BufferView::CreateFrom(), carla::multigpu::CommandHeader::id, carla::multigpu::Primary::MakeMessage(), and carla::multigpu::CommandHeader::size.
|
private |
Definition at line 78 of file router.h.
Referenced by ConnectSession(), and SetNewConnectionCallback().
|
private |
Definition at line 77 of file router.h.
Referenced by SetCallbacks().
|
private |
Definition at line 72 of file router.h.
Referenced by GetLocalEndpoint(), Router(), and SetCallbacks().
|
private |
Definition at line 74 of file router.h.
Referenced by Router(), SetCallbacks(), and Stop().
|
private |
Definition at line 70 of file router.h.
Referenced by ClearSessions(), ConnectSession(), DisconnectSession(), GetNextServer(), Write(), WriteToNext(), and WriteToOne().
|
private |
Definition at line 75 of file router.h.
Referenced by GetNextServer(), and WriteToNext().
|
private |
Definition at line 71 of file router.h.
Referenced by AsyncRun(), Router(), and Stop().
|
private |
Definition at line 76 of file router.h.
Referenced by SetCallbacks(), WriteToNext(), and WriteToOne().
|
private |
Definition at line 73 of file router.h.
Referenced by ClearSessions(), ConnectSession(), DisconnectSession(), GetNextServer(), Write(), and WriteToNext().