Communication: Atomic sync messages

If waitForMessageSync() is called in two threads for the same message
the callback for both will be invoked with the first send.
This commit is contained in:
Kyle Schwarz
2022-10-21 14:49:03 +00:00
parent 17b3018499
commit 0101467154
2 changed files with 8 additions and 6 deletions
@@ -88,6 +88,7 @@ protected:
std::atomic<bool> redirectingRead{false};
std::function<void(std::vector<uint8_t>&&)> redirectionFn;
std::mutex redirectingReadMutex; // Don't allow read to be disabled while in the redirectionFn
std::mutex syncMessageMutex;
void dispatchMessage(const std::shared_ptr<Message>& msg);
void handleInput(Packetizer& p, std::vector<uint8_t>& readBytes);