CARLA
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
carla::multigpu::Secondary Class Reference

#include <secondary.h>

+ Inheritance diagram for carla::multigpu::Secondary:

Public Types

using endpoint = boost::asio::ip::tcp::endpoint
 
using protocol_type = endpoint::protocol_type
 

Public Member Functions

void AsyncRun (size_t worker_threads)
 
void Connect ()
 
SecondaryCommands & GetCommander ()
 
bool IsConnected () const
 Whether the connection to the primary is up: false before the first connect, after a read fails (the primary is gone; this session is not resumed) and after Stop().
 
 Secondary (boost::asio::ip::tcp::endpoint ep, SecondaryCommands::callback_type callback)
 
 Secondary (std::string ip, uint16_t port, SecondaryCommands::callback_type callback)
 
void Stop ()
 Blocks until the io threads have exited.
 
void Write (Buffer buffer)
 
void Write (std::shared_ptr< const carla::streaming::detail::tcp::Message > message)
 
void Write (std::string text)
 
 ~Secondary ()
 

Static Public Member Functions

template<typename... Buffers>
static auto MakeMessage (Buffers... buffers)
 

Private Types

using message_type = std::shared_ptr< const carla::streaming::detail::tcp::Message >
 

Private Member Functions

void Disconnect ()
 Marks the connection lost and closes the socket. Strand only.
 
void ReadData ()
 
void Reconnect ()
 
void WriteNext ()
 Starts writing the front of the write queue. Strand only.
 
- Private Member Functions inherited from carla::profiler::LifetimeProfiled
 LifetimeProfiled ()=default
 
- Private Member Functions inherited from carla::NonCopyable
 NonCopyable ()=default
 
 NonCopyable (const NonCopyable &)=delete
 
 NonCopyable (NonCopyable &&)=delete
 
NonCopyable & operator= (const NonCopyable &)=delete
 
NonCopyable & operator= (NonCopyable &&)=delete
 

Private Attributes

std::shared_ptr< BufferPool > _buffer_pool
 
SecondaryCommands _commander
 
std::atomic_bool _connected {false}
 
boost::asio::steady_timer _connection_timer
 
std::atomic_bool _done {false}
 
boost::asio::ip::tcp::endpoint _endpoint
 
bool _is_writing = false
 
ThreadPool _pool
 
std::once_flag _run_flag
 
boost::asio::ip::tcp::socket _socket
 
boost::asio::io_context::strand _strand
 
uint64_t _write_generation = 0u
 Strand only: bumped by Disconnect(), so that the completion of a write it dropped leaves the queue alone.
 
std::deque< message_type > _write_queue
 Strand only: messages waiting to be written, oldest first, with a single write in flight so that two replies never interleave.
 

Detailed Description

Definition at line 37 of file secondary.h.

Member Typedef Documentation

◆ endpoint

using carla::multigpu::Secondary::endpoint = boost::asio::ip::tcp::endpoint

Definition at line 43 of file secondary.h.

◆ message_type

Definition at line 83 of file secondary.h.

◆ protocol_type

using carla::multigpu::Secondary::protocol_type = endpoint::protocol_type

Definition at line 44 of file secondary.h.

Constructor & Destructor Documentation

◆ Secondary() [1/2]

carla::multigpu::Secondary::Secondary ( boost::asio::ip::tcp::endpoint  ep,
SecondaryCommands::callback_type  callback 
)

Definition at line 30 of file secondary.cpp.

References _commander, and carla::multigpu::SecondaryCommands::set_callback().

◆ Secondary() [2/2]

carla::multigpu::Secondary::Secondary ( std::string  ip,
uint16_t  port,
SecondaryCommands::callback_type  callback 
)

◆ ~Secondary()

carla::multigpu::Secondary::~Secondary ( )

Definition at line 59 of file secondary.cpp.

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

Member Function Documentation

◆ AsyncRun()

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

Definition at line 134 of file secondary.cpp.

Referenced by Connect().

◆ Connect()

void carla::multigpu::Secondary::Connect ( )

◆ Disconnect()

void carla::multigpu::Secondary::Disconnect ( )
private

Marks the connection lost and closes the socket. Strand only.

Definition at line 198 of file secondary.cpp.

◆ GetCommander()

SecondaryCommands & carla::multigpu::Secondary::GetCommander ( )
inline

Definition at line 69 of file secondary.h.

References _commander.

◆ IsConnected()

bool carla::multigpu::Secondary::IsConnected ( ) const
inline

Whether the connection to the primary is up: false before the first connect, after a read fails (the primary is gone; this session is not resumed) and after Stop().

Any thread.

Definition at line 65 of file secondary.h.

References _connected.

◆ MakeMessage()

template<typename... Buffers>
static auto carla::multigpu::Secondary::MakeMessage ( Buffers...  buffers)
inlinestatic

Definition at line 74 of file secondary.h.

◆ ReadData()

void carla::multigpu::Secondary::ReadData ( )
private

◆ Reconnect()

void carla::multigpu::Secondary::Reconnect ( )
private

Definition at line 122 of file secondary.cpp.

References carla::time_duration::seconds().

◆ Stop()

void carla::multigpu::Secondary::Stop ( )

Blocks until the io threads have exited.

Must not be called from one of them (i.e. from a command callback).

Definition at line 111 of file secondary.cpp.

◆ Write() [1/3]

void carla::multigpu::Secondary::Write ( Buffer  buffer)

Definition at line 189 of file secondary.cpp.

References carla::BufferView::CreateFrom().

◆ Write() [2/3]

void carla::multigpu::Secondary::Write ( std::shared_ptr< const carla::streaming::detail::tcp::Message >  message)

Definition at line 138 of file secondary.cpp.

References DEBUG_ASSERT.

◆ Write() [3/3]

void carla::multigpu::Secondary::Write ( std::string  text)

Definition at line 193 of file secondary.cpp.

◆ WriteNext()

void carla::multigpu::Secondary::WriteNext ( )
private

Starts writing the front of the write queue. Strand only.

Definition at line 155 of file secondary.cpp.

References carla::log_error().

Member Data Documentation

◆ _buffer_pool

std::shared_ptr<BufferPool> carla::multigpu::Secondary::_buffer_pool
private

Definition at line 100 of file secondary.h.

◆ _commander

SecondaryCommands carla::multigpu::Secondary::_commander
private

Definition at line 111 of file secondary.h.

Referenced by Connect(), GetCommander(), Secondary(), and Secondary().

◆ _connected

std::atomic_bool carla::multigpu::Secondary::_connected {false}
private

Definition at line 102 of file secondary.h.

Referenced by IsConnected().

◆ _connection_timer

boost::asio::steady_timer carla::multigpu::Secondary::_connection_timer
private

Definition at line 99 of file secondary.h.

◆ _done

std::atomic_bool carla::multigpu::Secondary::_done {false}
private

Definition at line 101 of file secondary.h.

◆ _endpoint

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

Definition at line 97 of file secondary.h.

Referenced by Secondary().

◆ _is_writing

bool carla::multigpu::Secondary::_is_writing = false
private

Definition at line 106 of file secondary.h.

◆ _pool

ThreadPool carla::multigpu::Secondary::_pool
private

Definition at line 95 of file secondary.h.

Referenced by ~Secondary().

◆ _run_flag

std::once_flag carla::multigpu::Secondary::_run_flag
private

Definition at line 110 of file secondary.h.

Referenced by Connect().

◆ _socket

boost::asio::ip::tcp::socket carla::multigpu::Secondary::_socket
private

Definition at line 96 of file secondary.h.

◆ _strand

boost::asio::io_context::strand carla::multigpu::Secondary::_strand
private

Definition at line 98 of file secondary.h.

Referenced by Connect().

◆ _write_generation

uint64_t carla::multigpu::Secondary::_write_generation = 0u
private

Strand only: bumped by Disconnect(), so that the completion of a write it dropped leaves the queue alone.

Definition at line 109 of file secondary.h.

◆ _write_queue

std::deque<message_type> carla::multigpu::Secondary::_write_queue
private

Strand only: messages waiting to be written, oldest first, with a single write in flight so that two replies never interleave.

Definition at line 105 of file secondary.h.


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