CARLA
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
carla::multigpu::Primary Class Reference

A TCP server session. More...

#include <primary.h>

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

Public Types

using socket_type = boost::asio::ip::tcp::socket
 

Public Member Functions

void Close ()
 Post a job to close the session. More...
 
void Open (Listener::callback_function_type on_opened, Listener::callback_function_type on_closed, Listener::callback_function_type_response on_response)
 Starts the session and calls on_opened after successfully reading the stream id, and on_closed once the session is closed. More...
 
 Primary (boost::asio::io_context &io_context, time_duration timeout, Listener &server)
 
void ReadData ()
 read data More...
 
void Write (std::shared_ptr< const carla::streaming::detail::tcp::Message > message)
 Writes some data to the socket. More...
 
void Write (std::string text)
 Writes a string. More...
 
template<typename... Buffers>
void Write (Buffers... buffers)
 Writes some data to the socket. More...
 
 ~Primary ()
 

Static Public Member Functions

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

Private Member Functions

void CloseNow (boost::system::error_code ec=boost::system::error_code())
 
void StartTimer ()
 
- 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
 
NonCopyableoperator= (const NonCopyable &)=delete
 
NonCopyableoperator= (NonCopyable &&)=delete
 

Private Attributes

std::shared_ptr< BufferPool_buffer_pool
 
boost::asio::deadline_timer _deadline
 
bool _is_writing = false
 
Listener::callback_function_type _on_closed
 
Listener::callback_function_type_response _on_response
 
Listener_server
 
const size_t _session_id
 
socket_type _socket
 
boost::asio::io_context::strand _strand
 
time_duration _timeout
 

Friends

class Listener
 

Detailed Description

A TCP server session.

When a session opens, it reads from the socket a stream id object and passes itself to the callback functor. The session closes itself after timeout of inactivity is met.

Definition at line 31 of file primary.h.

Member Typedef Documentation

◆ socket_type

using carla::multigpu::Primary::socket_type = boost::asio::ip::tcp::socket

Definition at line 37 of file primary.h.

Constructor & Destructor Documentation

◆ Primary()

carla::multigpu::Primary::Primary ( boost::asio::io_context &  io_context,
time_duration  timeout,
Listener server 
)
explicit

Definition at line 27 of file primary.cpp.

◆ ~Primary()

carla::multigpu::Primary::~Primary ( )

Definition at line 41 of file primary.cpp.

References _socket.

Member Function Documentation

◆ Close()

void carla::multigpu::Primary::Close ( )

Post a job to close the session.

Definition at line 176 of file primary.cpp.

References _strand.

Referenced by StartTimer(), and Write().

+ Here is the caller graph for this function:

◆ CloseNow()

void carla::multigpu::Primary::CloseNow ( boost::system::error_code  ec = boost::system::error_code())
private

Definition at line 203 of file primary.cpp.

References _deadline, _on_closed, _session_id, _socket, and carla::log_debug().

Referenced by Write().

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

◆ MakeMessage()

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

Definition at line 54 of file primary.h.

References ReadData(), and Write().

Referenced by carla::multigpu::Router::Write(), Write(), carla::multigpu::Router::WriteToNext(), and carla::multigpu::Router::WriteToOne().

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

◆ Open()

void carla::multigpu::Primary::Open ( Listener::callback_function_type  on_opened,
Listener::callback_function_type  on_closed,
Listener::callback_function_type_response  on_response 
)

Starts the session and calls on_opened after successfully reading the stream id, and on_closed once the session is closed.

Definition at line 49 of file primary.cpp.

References _on_closed, _on_response, _socket, DEBUG_ASSERT, and ReadData().

+ Here is the call graph for this function:

◆ ReadData()

void carla::multigpu::Primary::ReadData ( )

read data

Definition at line 122 of file primary.cpp.

References _strand, DEBUG_ASSERT_EQ, DEBUG_ASSERT_NE, DEBUG_ONLY, and carla::log_error().

Referenced by MakeMessage(), and Open().

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

◆ StartTimer()

void carla::multigpu::Primary::StartTimer ( )
private

Definition at line 185 of file primary.cpp.

References _deadline, _session_id, Close(), carla::log_debug(), and carla::log_error().

Referenced by Write().

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

◆ Write() [1/3]

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

Writes some data to the socket.

Definition at line 68 of file primary.cpp.

References _strand, DEBUG_ASSERT, DEBUG_ONLY, and carla::log_error().

Referenced by MakeMessage(), and Write().

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

◆ Write() [2/3]

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

Writes a string.

Definition at line 98 of file primary.cpp.

References _strand.

◆ Write() [3/3]

template<typename... Buffers>
void carla::multigpu::Primary::Write ( Buffers...  buffers)
inline

Writes some data to the socket.

Definition at line 72 of file primary.h.

References Close(), CloseNow(), MakeMessage(), StartTimer(), and Write().

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ Listener

friend class Listener
friend

Definition at line 85 of file primary.h.

Member Data Documentation

◆ _buffer_pool

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

Definition at line 103 of file primary.h.

◆ _deadline

boost::asio::deadline_timer carla::multigpu::Primary::_deadline
private

Definition at line 95 of file primary.h.

Referenced by CloseNow(), and StartTimer().

◆ _is_writing

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

Definition at line 105 of file primary.h.

◆ _on_closed

Listener::callback_function_type carla::multigpu::Primary::_on_closed
private

Definition at line 99 of file primary.h.

Referenced by CloseNow(), and Open().

◆ _on_response

Listener::callback_function_type_response carla::multigpu::Primary::_on_response
private

Definition at line 101 of file primary.h.

Referenced by Open().

◆ _server

Listener& carla::multigpu::Primary::_server
private

Definition at line 87 of file primary.h.

◆ _session_id

const size_t carla::multigpu::Primary::_session_id
private

Definition at line 89 of file primary.h.

Referenced by CloseNow(), and StartTimer().

◆ _socket

socket_type carla::multigpu::Primary::_socket
private

Definition at line 91 of file primary.h.

Referenced by CloseNow(), Open(), and ~Primary().

◆ _strand

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

Definition at line 97 of file primary.h.

Referenced by Close(), ReadData(), and Write().

◆ _timeout

time_duration carla::multigpu::Primary::_timeout
private

Definition at line 93 of file primary.h.


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