Commit a2206d81 authored by Dave Watson's avatar Dave Watson Committed by Sara Golemon

Fix stop_ thread race

Summary: make it std::atomic

Reviewed By: @tudor

Differential Revision: D2191861
parent 9b980c75
...@@ -315,8 +315,7 @@ bool EventBase::loopBody(int flags) { ...@@ -315,8 +315,7 @@ bool EventBase::loopBody(int flags) {
std::chrono::steady_clock::now().time_since_epoch()).count(); std::chrono::steady_clock::now().time_since_epoch()).count();
} }
// TODO: Read stop_ atomically with an acquire barrier. while (!stop_.load(std::memory_order_acquire)) {
while (!stop_) {
++nextLoopCnt_; ++nextLoopCnt_;
// Run the before loop callbacks // Run the before loop callbacks
......
...@@ -671,7 +671,7 @@ bool runImmediatelyOrRunInEventBaseThreadAndWait(const Cob& fn); ...@@ -671,7 +671,7 @@ bool runImmediatelyOrRunInEventBaseThreadAndWait(const Cob& fn);
// stop_ is set by terminateLoopSoon() and is used by the main loop // stop_ is set by terminateLoopSoon() and is used by the main loop
// to determine if it should exit // to determine if it should exit
bool stop_; std::atomic<bool> stop_;
// The ID of the thread running the main loop. // The ID of the thread running the main loop.
// 0 if loop is not running. // 0 if loop is not running.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment