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

Side by Side Diff: components/shared_memory_seqlock/one_writer_seqlock.cc

Issue 1164563003: Extract device_sensors to /device via Mojofication (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "content/common/one_writer_seqlock.h" 5 #include "components/shared_memory_seqlock/one_writer_seqlock.h"
6 6
7 namespace content { 7 namespace shared_memory_seqlock {
8 8
9 OneWriterSeqLock::OneWriterSeqLock() 9 OneWriterSeqLock::OneWriterSeqLock() : sequence_(0) {
10 : sequence_(0) {
11 } 10 }
12 11
13 base::subtle::Atomic32 OneWriterSeqLock::ReadBegin() { 12 base::subtle::Atomic32 OneWriterSeqLock::ReadBegin() {
14 base::subtle::Atomic32 version; 13 base::subtle::Atomic32 version;
15 for (;;) { 14 for (;;) {
16 version = base::subtle::NoBarrier_Load(&sequence_); 15 version = base::subtle::NoBarrier_Load(&sequence_);
17 16
18 // If the counter is even, then the associated data might be in a 17 // If the counter is even, then the associated data might be in a
19 // consistent state, so we can try to read. 18 // consistent state, so we can try to read.
20 if ((version & 1) == 0) 19 if ((version & 1) == 0)
(...skipping 18 matching lines...) Expand all
39 // -- Store fence, write membarrier 38 // -- Store fence, write membarrier
40 } 39 }
41 40
42 void OneWriterSeqLock::WriteEnd() { 41 void OneWriterSeqLock::WriteEnd() {
43 // Increment the sequence to an even number to indicate the completion of 42 // Increment the sequence to an even number to indicate the completion of
44 // a write update. 43 // a write update.
45 // -- Store fence, write membarrier 44 // -- Store fence, write membarrier
46 base::subtle::Barrier_AtomicIncrement(&sequence_, 1); 45 base::subtle::Barrier_AtomicIncrement(&sequence_, 1);
47 } 46 }
48 47
49 } // namespace content 48 } // namespace shared_memory_seqlock
OLDNEW
« no previous file with comments | « components/shared_memory_seqlock/one_writer_seqlock.h ('k') | components/shared_memory_seqlock/one_writer_seqlock_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698