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

Side by Side Diff: content/common/gamepad_seqlock.h

Issue 8762013: add missing CONTENT_EXPORT (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_COMMON_GAMEPAD_SEQLOCK_H_ 5 #ifndef CONTENT_COMMON_GAMEPAD_SEQLOCK_H_
6 #define CONTENT_COMMON_GAMEPAD_SEQLOCK_H_ 6 #define CONTENT_COMMON_GAMEPAD_SEQLOCK_H_
7 7
8 #include "base/atomicops.h" 8 #include "base/atomicops.h"
9 #include "base/threading/platform_thread.h" 9 #include "base/threading/platform_thread.h"
10 #include "content/common/content_export.h"
10 11
11 namespace content { 12 namespace content {
12 13
13 // This SeqLock handles only *one* writer and multiple readers. It may be 14 // This SeqLock handles only *one* writer and multiple readers. It may be
14 // suitable for low-contention with relatively infrequent writes, and many 15 // suitable for low-contention with relatively infrequent writes, and many
15 // readers. See: 16 // readers. See:
16 // http://en.wikipedia.org/wiki/Seqlock 17 // http://en.wikipedia.org/wiki/Seqlock
17 // http://www.concurrencykit.org/doc/ck_sequence.html 18 // http://www.concurrencykit.org/doc/ck_sequence.html
18 // This implementation is based on ck_sequence.h from http://concurrencykit.org. 19 // This implementation is based on ck_sequence.h from http://concurrencykit.org.
19 // 20 //
20 // Currently, this is used in only one location. It may make sense to 21 // Currently, this is used in only one location. It may make sense to
21 // generalize with a higher-level construct that owns both the lock and the 22 // generalize with a higher-level construct that owns both the lock and the
22 // data buffer, if it is to be used more widely. 23 // data buffer, if it is to be used more widely.
23 // 24 //
24 // You must be very careful not to operate on potentially inconsistent read 25 // You must be very careful not to operate on potentially inconsistent read
25 // buffers. If the read must be retry'd, the data in the read buffer could 26 // buffers. If the read must be retry'd, the data in the read buffer could
26 // contain any random garbage. e.g., contained pointers might be 27 // contain any random garbage. e.g., contained pointers might be
27 // garbage, or indices could be out of range. Probably the only suitable thing 28 // garbage, or indices could be out of range. Probably the only suitable thing
28 // to do during the read loop is to make a copy of the data, and operate on it 29 // to do during the read loop is to make a copy of the data, and operate on it
29 // only after the read was found to be consistent. 30 // only after the read was found to be consistent.
30 class GamepadSeqLock { 31 class CONTENT_EXPORT GamepadSeqLock {
31 public: 32 public:
32 GamepadSeqLock(); 33 GamepadSeqLock();
33 base::subtle::Atomic32 ReadBegin(); 34 base::subtle::Atomic32 ReadBegin();
34 bool ReadRetry(base::subtle::Atomic32 version); 35 bool ReadRetry(base::subtle::Atomic32 version);
35 void WriteBegin(); 36 void WriteBegin();
36 void WriteEnd(); 37 void WriteEnd();
37 38
38 private: 39 private:
39 base::subtle::Atomic32 sequence_; 40 base::subtle::Atomic32 sequence_;
40 DISALLOW_COPY_AND_ASSIGN(GamepadSeqLock); 41 DISALLOW_COPY_AND_ASSIGN(GamepadSeqLock);
41 }; 42 };
42 43
43 } // namespace content 44 } // namespace content
44 45
45 #endif // CONTENT_COMMON_GAMEPAD_SEQLOCK_H_ 46 #endif // CONTENT_COMMON_GAMEPAD_SEQLOCK_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698