|
CARLA
|
A TCP server session. More...
#include <primary.h>
Inheritance 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. | |
| 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. | |
| Primary (boost::asio::io_context &io_context, time_duration timeout, Listener &server) | |
| void | ReadData () |
| read data | |
| template<typename... Buffers> | |
| void | Write (Buffers... buffers) |
| Writes some data to the socket. | |
| void | Write (std::shared_ptr< const carla::streaming::detail::tcp::Message > message) |
| Writes some data to the socket. | |
| void | Write (std::string text) |
| Writes a string. | |
| ~Primary () | |
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 | CloseNow (boost::system::error_code ec=boost::system::error_code()) |
| void | StartTimer () |
| 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 |
| boost::asio::steady_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 |
| std::deque< message_type > | _write_queue |
| Messages waiting to be written, oldest first, and whether one is being written. | |
Friends | |
| class | Listener |
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.
|
private |
| using carla::multigpu::Primary::socket_type = boost::asio::ip::tcp::socket |
|
explicit |
Definition at line 30 of file primary.cpp.
| carla::multigpu::Primary::~Primary | ( | ) |
Definition at line 44 of file primary.cpp.
References _socket.
| void carla::multigpu::Primary::Close | ( | ) |
Post a job to close the session.
Definition at line 188 of file primary.cpp.
References _strand.
Referenced by StartTimer().
|
private |
Definition at line 215 of file primary.cpp.
References _deadline, _on_closed, _session_id, _socket, and carla::log_debug().
|
inlinestatic |
Definition at line 55 of file primary.h.
Referenced by carla::multigpu::Router::SendLoadMap(), Write(), carla::multigpu::Router::Write(), Write(), carla::multigpu::Router::WriteToNext(), and carla::multigpu::Router::WriteToOne().
| 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 52 of file primary.cpp.
References _on_closed, _on_response, _socket, DEBUG_ASSERT, carla::multigpu::EnableKeepAlive(), and ReadData().
| void carla::multigpu::Primary::ReadData | ( | ) |
read data
Definition at line 130 of file primary.cpp.
References _strand, DEBUG_ASSERT_EQ, DEBUG_ASSERT_NE, DEBUG_ONLY, carla::multigpu::kMaxMultiGpuMessageBytes, and carla::log_error().
Referenced by Open().
|
private |
Definition at line 197 of file primary.cpp.
References _deadline, _session_id, Close(), carla::log_debug(), and carla::log_error().
|
inline |
Writes some data to the socket.
Definition at line 73 of file primary.h.
References MakeMessage(), and Write().
| void carla::multigpu::Primary::Write | ( | std::shared_ptr< const carla::streaming::detail::tcp::Message > | message | ) |
Writes some data to the socket.
Definition at line 72 of file primary.cpp.
References _strand, and DEBUG_ASSERT.
| void carla::multigpu::Primary::Write | ( | std::string | text | ) |
Writes a string.
Definition at line 124 of file primary.cpp.
References carla::BufferView::CreateFrom(), MakeMessage(), and Write().
|
private |
Starts writing the front of the write queue. Strand only.
Definition at line 89 of file primary.cpp.
References _deadline, _is_writing, _socket, _strand, _timeout, _write_queue, carla::log_error(), and carla::time_duration::to_chrono().
|
private |
|
private |
Definition at line 101 of file primary.h.
Referenced by CloseNow(), StartTimer(), and WriteNext().
|
private |
Definition at line 116 of file primary.h.
Referenced by WriteNext().
|
private |
Definition at line 105 of file primary.h.
Referenced by CloseNow(), and Open().
|
private |
|
private |
Definition at line 95 of file primary.h.
Referenced by CloseNow(), and StartTimer().
|
private |
Definition at line 97 of file primary.h.
Referenced by CloseNow(), Open(), WriteNext(), and ~Primary().
|
private |
Definition at line 103 of file primary.h.
Referenced by Close(), ReadData(), Write(), and WriteNext().
|
private |
Definition at line 99 of file primary.h.
Referenced by WriteNext().
|
private |
Messages waiting to be written, oldest first, and whether one is being written.
Strand only: a single write is ever in flight, so two large frames can never interleave on the socket.
Definition at line 114 of file primary.h.
Referenced by WriteNext().