SDK: Fix data races on the local semaphores

This commit is contained in:
Dennis Klein
2019-09-01 15:44:52 +02:00
committed by Dennis Klein
parent 5d6184cd1a
commit 1c49dde668
5 changed files with 22 additions and 21 deletions

View File

@@ -338,14 +338,15 @@ class BasicTopology : public AsioBase<Executor, Allocator>
auto ChangeState(TopologyTransition transition, Duration timeout = Duration(0))
-> std::pair<std::error_code, TopologyState>
{
tools::Semaphore blocker;
tools::SharedSemaphore blocker;
std::error_code ec;
TopologyState state;
AsyncChangeState(transition, timeout, [&](std::error_code _ec, TopologyState _state) mutable {
ec = _ec;
state = _state;
blocker.Signal();
});
AsyncChangeState(
transition, timeout, [&, blocker](std::error_code _ec, TopologyState _state) mutable {
ec = _ec;
state = _state;
blocker.Signal();
});
blocker.Wait();
return {ec, state};
}