• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "include/base/cef_atomic_flag.h"
6 
7 #include "include/base/cef_logging.h"
8 
9 namespace base {
10 
AtomicFlag()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   set_thread_checker_.DetachFromThread();
17 }
18 
19 AtomicFlag::~AtomicFlag() = default;
20 
Set()21 void AtomicFlag::Set() {
22   DCHECK(set_thread_checker_.CalledOnValidThread());
23   flag_.store(1, std::memory_order_release);
24 }
25 
UnsafeResetForTesting()26 void AtomicFlag::UnsafeResetForTesting() {
27   set_thread_checker_.DetachFromThread();
28   flag_.store(0, std::memory_order_release);
29 }
30 
31 }  // namespace base
32