Skip to content

Commit 4de2ff6

Browse files
author
Alexandre jublot
committed
merge: hotfix/asyncPacketTreat into dev
2 parents 5222268 + c574aab commit 4de2ff6

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/src/udp/AConnector.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
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

3536
void 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
);

0 commit comments

Comments
 (0)