blob: 3e025431a32f7cb514571818c7e50ab2c8e90aed [file] [log] [blame]
timurrrr@chromium.orgec4a0602009-10-16 22:09:11 +09001// Copyright (c) 2009 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 "base/atomic_flag.h"
6
7#include "base/dynamic_annotations.h"
8#include "base/logging.h"
9
10namespace base {
11
12void AtomicFlag::Set() {
13 DCHECK(!flag_);
14 // Set() method can't be called if the flag has already been set.
15
16 ANNOTATE_HAPPENS_BEFORE(&flag_);
17 base::subtle::Release_Store(&flag_, 1);
18}
19
20bool AtomicFlag::IsSet() const {
21 bool ret = base::subtle::Acquire_Load(&flag_) != 0;
22 if (ret) {
23 ANNOTATE_HAPPENS_AFTER(&flag_);
24 }
25 return ret;
26}
27
28} // namespace base