diff options
author | Craig Tiller <ctiller@google.com> | 2017-11-08 12:03:22 -0800 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2017-11-08 12:03:22 -0800 |
commit | 15626bb5274d4f0a65d9328af536b46f3a15e18b (patch) | |
tree | 3762fedc5257eefb305000f5d3eb9c6bf41bf5af /src/core | |
parent | fbf61bbc1abe671d9e5b1a8177a6be2abf9d5e23 (diff) |
Fix data race
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/lib/iomgr/lockfree_event.cc | 4 | ||||
-rw-r--r-- | src/core/lib/iomgr/lockfree_event.h | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/core/lib/iomgr/lockfree_event.cc b/src/core/lib/iomgr/lockfree_event.cc index 98e19f89df..af1bee4694 100644 --- a/src/core/lib/iomgr/lockfree_event.cc +++ b/src/core/lib/iomgr/lockfree_event.cc @@ -57,6 +57,10 @@ extern grpc_tracer_flag grpc_polling_trace; namespace grpc_core { +LockfreeEvent::LockfreeEvent() { + gpr_atm_no_barrier_store(&state_, kClosureNotReady); +} + LockfreeEvent::~LockfreeEvent() { gpr_atm curr = gpr_atm_no_barrier_load(&state_); if (curr & kShutdownBit) { diff --git a/src/core/lib/iomgr/lockfree_event.h b/src/core/lib/iomgr/lockfree_event.h index 47d0089c01..c667dcd3bc 100644 --- a/src/core/lib/iomgr/lockfree_event.h +++ b/src/core/lib/iomgr/lockfree_event.h @@ -29,7 +29,7 @@ namespace grpc_core { class LockfreeEvent { public: - LockfreeEvent() = default; + LockfreeEvent(); ~LockfreeEvent(); LockfreeEvent(const LockfreeEvent&) = delete; @@ -46,7 +46,7 @@ class LockfreeEvent { private: enum State { kClosureNotReady = 0, kClosureReady = 2, kShutdownBit = 1 }; - gpr_atm state_ = kClosureNotReady; + gpr_atm state_; }; } // namespace grpc_core |