Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::buffer_factory Struct Reference
Inheritance diagram for sysio::buffer_factory:

Public Member Functions

const send_buffer_typeget_send_buffer (const net_message &m)
 caches result for subsequent calls, only provide same net_message instance for each invocation
 

Static Protected Member Functions

static send_buffer_type create_send_buffer (const net_message &m)
 
template<typename T >
static send_buffer_type create_send_buffer (uint32_t which, const T &v)
 

Protected Attributes

send_buffer_type send_buffer
 

Detailed Description

Definition at line 1322 of file net_plugin.cpp.

Member Function Documentation

◆ create_send_buffer() [1/2]

static send_buffer_type sysio::buffer_factory::create_send_buffer ( const net_message & m)
inlinestaticprotected

Definition at line 1336 of file net_plugin.cpp.

1336 {
1337 const uint32_t payload_size = fc::raw::pack_size( m );
1338
1339 const char* const header = reinterpret_cast<const char* const>(&payload_size); // avoid variable size encoding of uint32_t
1340 const size_t buffer_size = message_header_size + payload_size;
1341
1342 auto send_buffer = std::make_shared<vector<char>>(buffer_size);
1343 fc::datastream<char*> ds( send_buffer->data(), buffer_size);
1344 ds.write( header, message_header_size );
1345 fc::raw::pack( ds, m );
1346
1347 return send_buffer;
1348 }
static const Segment ds(Segment::ds)
void pack(Stream &s, const std::deque< T > &value)
Definition raw.hpp:531
size_t pack_size(const T &v)
Definition raw.hpp:671
constexpr auto message_header_size
unsigned int uint32_t
Definition stdint.h:126
send_buffer_type send_buffer
Here is the call graph for this function:

◆ create_send_buffer() [2/2]

template<typename T >
static send_buffer_type sysio::buffer_factory::create_send_buffer ( uint32_t which,
const T & v )
inlinestaticprotected

Definition at line 1351 of file net_plugin.cpp.

1351 {
1352 // match net_message static_variant pack
1353 const uint32_t which_size = fc::raw::pack_size( unsigned_int( which ) );
1354 const uint32_t payload_size = which_size + fc::raw::pack_size( v );
1355
1356 const char* const header = reinterpret_cast<const char* const>(&payload_size); // avoid variable size encoding of uint32_t
1357 const size_t buffer_size = message_header_size + payload_size;
1358
1359 auto send_buffer = std::make_shared<vector<char>>( buffer_size );
1360 fc::datastream<char*> ds( send_buffer->data(), buffer_size );
1361 ds.write( header, message_header_size );
1362 fc::raw::pack( ds, unsigned_int( which ) );
1363 fc::raw::pack( ds, v );
1364
1365 return send_buffer;
1366 }
Here is the call graph for this function:

◆ get_send_buffer()

const send_buffer_type & sysio::buffer_factory::get_send_buffer ( const net_message & m)
inline

Definition at line 1325 of file net_plugin.cpp.

1325 {
1326 if( !send_buffer ) {
1328 }
1329 return send_buffer;
1330 }
static send_buffer_type create_send_buffer(const net_message &m)
Here is the caller graph for this function:

Member Data Documentation

◆ send_buffer

send_buffer_type sysio::buffer_factory::send_buffer
protected

Definition at line 1333 of file net_plugin.cpp.


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