| OLD | NEW |
| 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 #include "content/common/one_writer_seqlock.h" | 5 #include "content/common/one_writer_seqlock.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include "base/atomic_ref_count.h" | 9 #include "base/atomic_ref_count.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 unsigned a, b, c; | 21 unsigned a, b, c; |
| 22 }; | 22 }; |
| 23 | 23 |
| 24 class BasicSeqLockTestThread : public PlatformThread::Delegate { | 24 class BasicSeqLockTestThread : public PlatformThread::Delegate { |
| 25 public: | 25 public: |
| 26 BasicSeqLockTestThread() {} | 26 BasicSeqLockTestThread() {} |
| 27 | 27 |
| 28 void Init( | 28 void Init( |
| 29 content::OneWriterSeqLock* seqlock, | 29 content::OneWriterSeqLock* seqlock, |
| 30 TestData* data, | 30 TestData* data, |
| 31 base::subtle::Atomic32* ready) { | 31 base::AtomicRefCount* ready) { |
| 32 seqlock_ = seqlock; | 32 seqlock_ = seqlock; |
| 33 data_ = data; | 33 data_ = data; |
| 34 ready_ = ready; | 34 ready_ = ready; |
| 35 } | 35 } |
| 36 void ThreadMain() override { | 36 void ThreadMain() override { |
| 37 while (AtomicRefCountIsZero(ready_)) { | 37 while (AtomicRefCountIsZero(ready_)) { |
| 38 PlatformThread::YieldCurrentThread(); | 38 PlatformThread::YieldCurrentThread(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 for (unsigned i = 0; i < 1000; ++i) { | 41 for (unsigned i = 0; i < 1000; ++i) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 96 |
| 97 if (AtomicRefCountIsZero(&ready)) | 97 if (AtomicRefCountIsZero(&ready)) |
| 98 break; | 98 break; |
| 99 } | 99 } |
| 100 | 100 |
| 101 for (unsigned i = 0; i < kNumReaderThreads; ++i) | 101 for (unsigned i = 0; i < kNumReaderThreads; ++i) |
| 102 PlatformThread::Join(handles[i]); | 102 PlatformThread::Join(handles[i]); |
| 103 } | 103 } |
| 104 | 104 |
| 105 } // namespace base | 105 } // namespace base |
| OLD | NEW |