Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::queued_buffer Class Reference
Inheritance diagram for sysio::queued_buffer:
Collaboration diagram for sysio::queued_buffer:

Public Member Functions

void clear_write_queue ()
 
void clear_out_queue ()
 
uint32_t write_queue_size () const
 
bool is_out_queue_empty () const
 
bool ready_to_send () const
 
bool add_write_queue (const std::shared_ptr< vector< char > > &buff, std::function< void(boost::system::error_code, std::size_t)> callback, bool to_sync_queue)
 
void fill_out_buffer (std::vector< boost::asio::const_buffer > &bufs)
 
void out_callback (boost::system::error_code ec, std::size_t w)
 

Detailed Description

Definition at line 448 of file net_plugin.cpp.

Member Function Documentation

◆ add_write_queue()

bool sysio::queued_buffer::add_write_queue ( const std::shared_ptr< vector< char > > & buff,
std::function< void(boost::system::error_code, std::size_t)> callback,
bool to_sync_queue )
inline

Definition at line 481 of file net_plugin.cpp.

483 {
484 std::lock_guard<std::mutex> g( _mtx );
485 if( to_sync_queue ) {
486 _sync_write_queue.push_back( {buff, callback} );
487 } else {
488 _write_queue.push_back( {buff, callback} );
489 }
490 _write_queue_size += buff->size();
491 if( _write_queue_size > 2 * def_max_write_queue_size ) {
492 return false;
493 }
494 return true;
495 }
constexpr auto def_max_write_queue_size
Here is the caller graph for this function:

◆ clear_out_queue()

void sysio::queued_buffer::clear_out_queue ( )
inline

Definition at line 457 of file net_plugin.cpp.

457 {
458 std::lock_guard<std::mutex> g( _mtx );
459 while ( _out_queue.size() > 0 ) {
460 _out_queue.pop_front();
461 }
462 }
Here is the caller graph for this function:

◆ clear_write_queue()

void sysio::queued_buffer::clear_write_queue ( )
inline

Definition at line 450 of file net_plugin.cpp.

450 {
451 std::lock_guard<std::mutex> g( _mtx );
452 _write_queue.clear();
453 _sync_write_queue.clear();
454 _write_queue_size = 0;
455 }
Here is the caller graph for this function:

◆ fill_out_buffer()

void sysio::queued_buffer::fill_out_buffer ( std::vector< boost::asio::const_buffer > & bufs)
inline

Definition at line 497 of file net_plugin.cpp.

497 {
498 std::lock_guard<std::mutex> g( _mtx );
499 if( _sync_write_queue.size() > 0 ) { // always send msgs from sync_write_queue first
500 fill_out_buffer( bufs, _sync_write_queue );
501 } else { // postpone real_time write_queue if sync queue is not empty
502 fill_out_buffer( bufs, _write_queue );
503 SYS_ASSERT( _write_queue_size == 0, plugin_exception, "write queue size expected to be zero" );
504 }
505 }
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
Definition exceptions.hpp:7
void fill_out_buffer(std::vector< boost::asio::const_buffer > &bufs)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_out_queue_empty()

bool sysio::queued_buffer::is_out_queue_empty ( ) const
inline

Definition at line 469 of file net_plugin.cpp.

469 {
470 std::lock_guard<std::mutex> g( _mtx );
471 return _out_queue.empty();
472 }

◆ out_callback()

void sysio::queued_buffer::out_callback ( boost::system::error_code ec,
std::size_t w )
inline

Definition at line 507 of file net_plugin.cpp.

507 {
508 std::lock_guard<std::mutex> g( _mtx );
509 for( auto& m : _out_queue ) {
510 m.callback( ec, w );
511 }
512 }

◆ ready_to_send()

bool sysio::queued_buffer::ready_to_send ( ) const
inline

Definition at line 474 of file net_plugin.cpp.

474 {
475 std::lock_guard<std::mutex> g( _mtx );
476 // if out_queue is not empty then async_write is in progress
477 return ((!_sync_write_queue.empty() || !_write_queue.empty()) && _out_queue.empty());
478 }
Here is the caller graph for this function:

◆ write_queue_size()

uint32_t sysio::queued_buffer::write_queue_size ( ) const
inline

Definition at line 464 of file net_plugin.cpp.

464 {
465 std::lock_guard<std::mutex> g( _mtx );
466 return _write_queue_size;
467 }
Here is the caller graph for this function:

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