CARLA
Public Member Functions | Private Member Functions | Private Attributes | List of all members
carla::multigpu::Router Class Reference

#include <router.h>

+ Inheritance diagram for carla::multigpu::Router:
+ Collaboration diagram for carla::multigpu::Router:

Public Member Functions

void AsyncRun (size_t worker_threads)
 
PrimaryCommandsGetCommander ()
 
boost::asio::ip::tcp::endpoint GetLocalEndpoint () const
 
std::weak_ptr< PrimaryGetNextServer ()
 
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< SessionInfoWriteToNext (MultiGPUCommand id, Buffer &&buffer)
 
std::future< SessionInfoWriteToOne (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
 

Detailed Description

Definition at line 35 of file router.h.

Constructor & Destructor Documentation

◆ Router() [1/2]

carla::multigpu::Router::Router ( void  )

Definition at line 15 of file router.cpp.

◆ Router() [2/2]

carla::multigpu::Router::Router ( uint16_t  port)
explicit

Definition at line 29 of file router.cpp.

References _endpoint, _listener, _pool, and carla::ThreadPool::io_context().

+ Here is the call graph for this function:

◆ ~Router()

carla::multigpu::Router::~Router ( )

Definition at line 18 of file router.cpp.

References Stop().

+ Here is the call graph for this function:

Member Function Documentation

◆ AsyncRun()

void carla::multigpu::Router::AsyncRun ( size_t  worker_threads)

Definition at line 78 of file router.cpp.

References _pool, and carla::ThreadPool::AsyncRun().

+ Here is the call graph for this function:

◆ ClearSessions()

void carla::multigpu::Router::ClearSessions ( )
private

Definition at line 106 of file router.cpp.

References _mutex, _sessions, and carla::log_info().

Referenced by Stop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ConnectSession()

void carla::multigpu::Router::ConnectSession ( std::shared_ptr< Primary session)
private

Definition at line 86 of file router.cpp.

References _callback, _mutex, _sessions, DEBUG_ASSERT, and carla::log_info().

+ Here is the call graph for this function:

◆ DisconnectSession()

void carla::multigpu::Router::DisconnectSession ( std::shared_ptr< Primary session)
private

Definition at line 96 of file router.cpp.

References _mutex, _sessions, DEBUG_ASSERT, and carla::log_info().

+ Here is the call graph for this function:

◆ GetCommander()

PrimaryCommands& carla::multigpu::Router::GetCommander ( )
inline

Definition at line 58 of file router.h.

References carla::multigpu::SessionInfo::session.

◆ GetLocalEndpoint()

boost::asio::ip::tcp::endpoint carla::multigpu::Router::GetLocalEndpoint ( ) const

Definition at line 82 of file router.cpp.

References _endpoint.

◆ GetNextServer()

std::weak_ptr< Primary > carla::multigpu::Router::GetNextServer ( )

Definition at line 188 of file router.cpp.

References _mutex, _next, and _sessions.

◆ HasClientsConnected()

bool carla::multigpu::Router::HasClientsConnected ( )
inline

Definition at line 54 of file router.h.

◆ SetCallbacks()

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().

+ Here is the call graph for this function:

◆ SetNewConnectionCallback()

void carla::multigpu::Router::SetNewConnectionCallback ( std::function< void(void)>  func)

Definition at line 73 of file router.cpp.

References _callback.

◆ Stop()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Write()

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.

+ Here is the call graph for this function:

◆ WriteToNext()

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.

+ Here is the call graph for this function:

◆ WriteToOne()

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.

+ Here is the call graph for this function:

Member Data Documentation

◆ _callback

std::function<void(void)> carla::multigpu::Router::_callback
private

Definition at line 78 of file router.h.

Referenced by ConnectSession(), and SetNewConnectionCallback().

◆ _commander

PrimaryCommands carla::multigpu::Router::_commander
private

Definition at line 77 of file router.h.

Referenced by SetCallbacks().

◆ _endpoint

boost::asio::ip::tcp::endpoint carla::multigpu::Router::_endpoint
private

Definition at line 72 of file router.h.

Referenced by GetLocalEndpoint(), Router(), and SetCallbacks().

◆ _listener

std::shared_ptr<Listener> carla::multigpu::Router::_listener
private

Definition at line 74 of file router.h.

Referenced by Router(), SetCallbacks(), and Stop().

◆ _mutex

std::mutex carla::multigpu::Router::_mutex
private

◆ _next

uint32_t carla::multigpu::Router::_next
private

Definition at line 75 of file router.h.

Referenced by GetNextServer(), and WriteToNext().

◆ _pool

ThreadPool carla::multigpu::Router::_pool
private

Definition at line 71 of file router.h.

Referenced by AsyncRun(), Router(), and Stop().

◆ _promises

std::unordered_map<Primary *, std::shared_ptr<std::promise<SessionInfo> > > carla::multigpu::Router::_promises
private

Definition at line 76 of file router.h.

Referenced by SetCallbacks(), WriteToNext(), and WriteToOne().

◆ _sessions

std::vector<std::shared_ptr<Primary> > carla::multigpu::Router::_sessions
private

The documentation for this class was generated from the following files: