File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77
88#include < iostream>
99#include < mutex>
10+ #include < future>
1011#include " udp/AConnector.hpp"
1112#include " polymorph/network/SerializerTrait.hpp"
1213#include " polymorph/network/dto/ACKDto.hpp"
@@ -34,7 +35,6 @@ void polymorph::network::udp::AConnector::startConnection()
3435
3536void polymorph::network::udp::AConnector::_doReceive ()
3637{
37- _receiveInProgress = false ;
3838 _socket.async_receive_from (asio::buffer (_receiveBuffer), _endpoint,
3939 [this ](const asio::error_code &error, std::size_t bytesReceived) {
4040 if (error == asio::error::operation_aborted || _stopping)
@@ -43,9 +43,12 @@ void polymorph::network::udp::AConnector::_doReceive()
4343 std::cerr << " Error while receiving data: " << error.message () << std::endl;
4444 return ;
4545 }
46- _receiveInProgress = true ;
47- std::vector<std::byte> data (_receiveBuffer.begin (), _receiveBuffer.begin () + bytesReceived);
48- _determinePacket (data);
46+ std::async (std::launch::async, [this , bytesReceived]() {
47+ _receiveInProgress = true ;
48+ std::vector<std::byte> data (_receiveBuffer.begin (), _receiveBuffer.begin () + bytesReceived);
49+ _determinePacket (data);
50+ _receiveInProgress = false ;
51+ });
4952 _doReceive ();
5053 }
5154 );
You can’t perform that action at this time.
0 commit comments