Skip to content
Snippets Groups Projects
Unverified Commit ad41cd62 authored by Sébastien Blin's avatar Sébastien Blin
Browse files

mxsock: replace async by a thread and fix shutdown

Change-Id: Ie5c14606c01c5c277b7939889eb035caa6607b52
parent 84cf2b44
Branches
No related tags found
No related merge requests found
...@@ -45,14 +45,13 @@ public: ...@@ -45,14 +45,13 @@ public:
: parent_(parent) : parent_(parent)
, deviceId(deviceId) , deviceId(deviceId)
, endpoint(std::move(endpoint)) , endpoint(std::move(endpoint))
, eventLoopFut_ {std::async(std::launch::async, [this] { , eventLoopThread_ {[this] {
try { try {
stop.store(false);
eventLoop(); eventLoop();
} catch (const std::exception& e) { } catch (const std::exception& e) {
JAMI_ERR() << "[CNX] peer connection event loop failure: " << e.what(); JAMI_ERR() << "[CNX] peer connection event loop failure: " << e.what();
} }
})} }}
{} {}
~Impl() ~Impl()
...@@ -69,6 +68,7 @@ public: ...@@ -69,6 +68,7 @@ public:
} }
sockets.clear(); sockets.clear();
} }
eventLoopThread_.join();
} }
void shutdown() void shutdown()
...@@ -129,8 +129,8 @@ public: ...@@ -129,8 +129,8 @@ public:
std::map<uint16_t, onChannelReadyCb> channelCbs {}; std::map<uint16_t, onChannelReadyCb> channelCbs {};
// Main loop to parse incoming packets // Main loop to parse incoming packets
std::future<void> eventLoopFut_ {}; std::atomic_bool stop {false};
std::atomic_bool stop {}; std::thread eventLoopThread_ {};
// Multiplexed available datas // Multiplexed available datas
std::map<uint16_t, std::unique_ptr<ChannelInfo>> channelDatas_ {}; std::map<uint16_t, std::unique_ptr<ChannelInfo>> channelDatas_ {};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment