Commit 349b2329 authored by David Goldblatt's avatar David Goldblatt Committed by Facebook Github Bot

AtomicReadMostlyMainPtr: add a DCHECK.

Summary:
Previously this was just a comment that we documented; but it's easy to check
it directly.

Reviewed By: yfeldblum

Differential Revision: D13678337

fbshipit-source-id: 24990a732a2cc0019e90e294603bb8254a5cbc37
parent cef3decf
...@@ -144,7 +144,8 @@ class AtomicReadMostlyMainPtr { ...@@ -144,7 +144,8 @@ class AtomicReadMostlyMainPtr {
auto index = curMainPtrIndex_.load(std::memory_order_relaxed); auto index = curMainPtrIndex_.load(std::memory_order_relaxed);
ReadMostlyMainPtr<T>& oldMain = mainPtrs_[index]; ReadMostlyMainPtr<T>& oldMain = mainPtrs_[index];
ReadMostlyMainPtr<T>& newMain = mainPtrs_[1 - index]; ReadMostlyMainPtr<T>& newMain = mainPtrs_[1 - index];
// From the entry invariant, there's no readers accessing newMain right now. DCHECK(newMain.get() == nullptr)
<< "Invariant should ensure that at most one version is non-null";
newMain.reset(std::move(ptr)); newMain.reset(std::move(ptr));
// If order is acq_rel, it should degrade to just release, since this is a // If order is acq_rel, it should degrade to just release, since this is a
// store rather than an RMW. (Of course, this is such a slow method that we // store rather than an RMW. (Of course, this is such a slow method that we
......
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