diff options
-rw-r--r-- | src/mongo/executor/network_interface_asio_test_utils.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/mongo/executor/network_interface_asio_test_utils.h b/src/mongo/executor/network_interface_asio_test_utils.h index 54424735b9b..a95da3dfc5f 100644 --- a/src/mongo/executor/network_interface_asio_test_utils.h +++ b/src/mongo/executor/network_interface_asio_test_utils.h @@ -34,7 +34,6 @@ #include <vector> #include "mongo/executor/task_executor.h" -#include "mongo/platform/atomic_word.h" #include "mongo/stdx/condition_variable.h" #include "mongo/stdx/future.h" #include "mongo/stdx/mutex.h" @@ -120,26 +119,29 @@ private: class CountdownLatch { public: - CountdownLatch(uint32_t count) : _count(count) {} + explicit CountdownLatch(uint32_t count) : _count(count) {} void countDown() { - if (_count.load() == 0) { + stdx::lock_guard<stdx::mutex> lk(_mtx); + if (_count == 0) { return; } - if (_count.subtractAndFetch(1) == 0) { + + --_count; + if (_count == 0) { _cv.notify_all(); } } void await() { stdx::unique_lock<stdx::mutex> lk(_mtx); - _cv.wait(lk, [&] { return _count.load() == 0; }); + _cv.wait(lk, [&] { return _count == 0; }); } private: - stdx::condition_variable _cv; stdx::mutex _mtx; - AtomicUInt32 _count; + stdx::condition_variable _cv; + size_t _count; }; namespace helpers { |