| 6 |
| 7 | #include "base/logging.h" |
| 8 |
| 9 | namespace base { |
| 10 |
| 11 | AtomicFlag::AtomicFlag() { |
| 12 | // It doesn't matter where the AtomicFlag is built so long as it's always |
| 13 | // Set() from the same sequence after. Note: the sequencing requirements are |
| 14 | // necessary for IsSet()'s callers to know which sequence's memory operations |
| 15 | // they are synchronized with. |
| 16 | DETACH_FROM_SEQUENCE(set_sequence_checker_); |
| 17 | } |
| 18 |
| 19 | AtomicFlag::~AtomicFlag() = default; |
| 20 |
| 21 | void AtomicFlag::Set() { |
| 22 | DCHECK_CALLED_ON_VALID_SEQUENCE(set_sequence_checker_); |
| 23 | flag_.store(1, std::memory_order_release); |
| 24 | } |
| 25 |
| 26 | void AtomicFlag::UnsafeResetForTesting() { |
| 27 | DETACH_FROM_SEQUENCE(set_sequence_checker_); |
| 28 | flag_.store(0, std::memory_order_release); |
| 29 | } |
| 30 |
| 31 | } // namespace base |
| 32 |