Changeset 192:0ee54c98dcc5 in finroc_plugins_tcp


Ignore:
Timestamp:
29.08.2021 17:02:32 (15 months ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
17.03
Phase:
public
Message:

Adapts to optimizations in rrlib_serialization

Location:
internal
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • internal/tConnection.cpp

    r190 r192  
    358358  { 
    359359    // read size of next structure buffer 
    360     boost::asio::async_read(*(connection->socket), boost::asio::mutable_buffers_1(connection->read_size_buffer.GetPointer(), 4), *this); 
     360    boost::asio::async_read(*(connection->socket), boost::asio::mutable_buffers_1(connection->read_size_buffer.data(), 4), *this); 
    361361  } 
    362362 
     
    400400        } 
    401401 
    402         connection->read_buffer = rrlib::serialization::tFixedBuffer(bytes + 5000); 
     402        connection->read_buffer = tConnection::tReadBuffer(bytes + 5000); 
    403403      } 
    404404      if (!connection->IsClosed()) 
     
    415415  void ProcessMessageBatch() 
    416416  { 
    417     continue_at = connection->ProcessIncomingMessageBatch(rrlib::serialization::tFixedBuffer(connection->read_buffer.GetPointer(), connection->GetBytesToRead()), continue_at); 
     417    continue_at = connection->ProcessIncomingMessageBatch(rrlib::serialization::tConstByteBuffer(connection->read_buffer.GetPointer(), connection->GetBytesToRead()), continue_at); 
    418418 
    419419    if (continue_at == 0) 
     
    421421      // read size of next structure buffer 
    422422      connection->bytes_to_read = 0; 
    423       boost::asio::async_read(*(connection->socket), boost::asio::mutable_buffers_1(connection->read_size_buffer.GetPointer(), 4), *this); 
     423      boost::asio::async_read(*(connection->socket), boost::asio::mutable_buffers_1(connection->read_size_buffer.data(), 4), *this); 
    424424    } 
    425425    else 
     
    560560  { 
    561561    // read size of next structure buffer 
    562     boost::asio::async_read(*(connection->socket), boost::asio::mutable_buffers_1(connection->read_size_buffer.GetPointer(), 4), *this); 
     562    boost::asio::async_read(*(connection->socket), boost::asio::mutable_buffers_1(connection->read_size_buffer.data(), 4), *this); 
    563563  } 
    564564 
     
    614614      if ((!read_buffer) || read_buffer->Capacity() < bytes) 
    615615      { 
    616         read_buffer.reset(new rrlib::serialization::tFixedBuffer(bytes)); 
     616        read_buffer.reset(new rrlib::serialization::tByteBufferStorage<>(bytes)); 
    617617      } 
    618618      boost::asio::async_read(*(connection->socket), boost::asio::mutable_buffers_1(read_buffer->GetPointer(), bytes), *this); 
     
    633633    // read size of next structure buffer 
    634634    connection->bytes_to_read = 0; 
    635     boost::asio::async_read(*(connection->socket), boost::asio::mutable_buffers_1(connection->read_size_buffer.GetPointer(), 4), *this); 
     635    boost::asio::async_read(*(connection->socket), boost::asio::mutable_buffers_1(connection->read_size_buffer.data(), 4), *this); 
    636636  } 
    637637 
     
    639639 
    640640  std::shared_ptr<tConnection> connection; 
    641   std::shared_ptr<rrlib::serialization::tFixedBuffer> read_buffer; 
     641  std::shared_ptr<rrlib::serialization::tByteBufferStorage<>> read_buffer; 
    642642}; 
    643643 
     
    650650  socket(socket), 
    651651  ready(false), 
    652   read_size_buffer(4), 
    653652  read_buffer(cINITIAL_READ_BUFFER_SIZE), 
    654653  bytes_to_read(0), 
     
    706705size_t tConnection::GetBytesToRead() 
    707706{ 
    708   rrlib::serialization::tMemoryBuffer buffer(read_size_buffer.GetPointer(), read_size_buffer.Capacity()); 
     707  rrlib::serialization::tMemoryBuffer buffer(read_size_buffer.data(), read_size_buffer.size()); 
    709708  rrlib::serialization::tInputStream stream(buffer); 
    710709  bytes_to_read = stream.ReadInt(); 
  • internal/tConnection.h

    r155 r192  
    138138 
    139139  /*! Buffer to store size of next message batch to read in */ 
    140   rrlib::serialization::tFixedBuffer read_size_buffer; 
     140  std::array<char, 4> read_size_buffer; 
    141141 
    142142  /*! Buffer to store next message batch to read in */ 
    143   rrlib::serialization::tFixedBuffer read_buffer; 
     143  typedef rrlib::serialization::tByteBufferStorage<true> tReadBuffer; 
     144  tReadBuffer read_buffer; 
    144145 
    145146  /*! Contains number of bytes to read in next message batch */ 
Note: See TracChangeset for help on using the changeset viewer.