Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: base/atomic_flag.h

Issue 276002: Add AtomicFlag class to base/...... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/atomic_flag.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // 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 #ifndef BASE_ATOMIC_FLAG_H_
6 #define BASE_ATOMIC_FLAG_H_
7
8 #include "base/atomicops.h"
9
10 namespace base {
11
12 // AtomicFlag allows threads to notify each other for a single occurrence
13 // of a single event. It maintains an abstract boolean "flag" that transitions
14 // to true at most once. It provides calls to query the boolean.
15 //
16 // Memory ordering: For any threads X and Y, if X calls Set(), then any
17 // action taken by X before it calls Set() is visible to thread Y after
18 // Y receives a true return value from IsSet().
19 class AtomicFlag {
20 public:
21 // Sets "flag_" to "initial_value".
22 explicit AtomicFlag(bool initial_value = false)
23 : flag_(initial_value ? 1 : 0) { }
24 ~AtomicFlag() {}
25
26 void Set(); // Set "flag_" to true. May be called only once.
27 bool IsSet() const; // Return "flag_".
28
29 private:
30 base::subtle::Atomic32 flag_;
31
32 DISALLOW_COPY_AND_ASSIGN(AtomicFlag);
33 };
34
35 } // namespace base
36
37 #endif // BASE_ATOMIC_FLAG_H_
OLDNEW
« no previous file with comments | « no previous file | base/atomic_flag.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698