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

Unified Diff: device/base/synchronization/one_writer_seqlock_unittest.cc

Issue 2358123005: Move OneWriterSeqLock and SharedMemorySeqLockBuffer from content/ to device/base/synchronization (Closed)
Patch Set: Few fixes Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: device/base/synchronization/one_writer_seqlock_unittest.cc
diff --git a/content/common/one_writer_seqlock_unittest.cc b/device/base/synchronization/one_writer_seqlock_unittest.cc
similarity index 73%
rename from content/common/one_writer_seqlock_unittest.cc
rename to device/base/synchronization/one_writer_seqlock_unittest.cc
index 5fb184875f8326c4d2285387500e245db6f478a1..e8e989db87563869d52cb6c72c504d4367cc754b 100644
--- a/content/common/one_writer_seqlock_unittest.cc
+++ b/device/base/synchronization/one_writer_seqlock_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/common/one_writer_seqlock.h"
+#include "device/base/synchronization/one_writer_seqlock.h"
#include <stdlib.h>
@@ -13,7 +13,7 @@
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace base {
+namespace device {
// Basic test to make sure that basic operation works correctly.
@@ -21,21 +21,20 @@ struct TestData {
unsigned a, b, c;
};
-class BasicSeqLockTestThread : public PlatformThread::Delegate {
+class BasicSeqLockTestThread : public base::PlatformThread::Delegate {
public:
BasicSeqLockTestThread() {}
- void Init(
- content::OneWriterSeqLock* seqlock,
- TestData* data,
- base::AtomicRefCount* ready) {
+ void Init(device::OneWriterSeqLock* seqlock,
Reilly Grant (use Gerrit) 2016/09/30 02:05:10 This is in the device namespace so device:: isn't
+ TestData* data,
+ base::AtomicRefCount* ready) {
seqlock_ = seqlock;
data_ = data;
ready_ = ready;
}
void ThreadMain() override {
- while (AtomicRefCountIsZero(ready_)) {
- PlatformThread::YieldCurrentThread();
+ while (base::AtomicRefCountIsZero(ready_)) {
+ base::PlatformThread::YieldCurrentThread();
}
for (unsigned i = 0; i < 1000; ++i) {
@@ -50,11 +49,11 @@ class BasicSeqLockTestThread : public PlatformThread::Delegate {
EXPECT_EQ(copy.c, copy.b + copy.a);
}
- AtomicRefCountDec(ready_);
+ base::AtomicRefCountDec(ready_);
}
private:
- content::OneWriterSeqLock* seqlock_;
+ device::OneWriterSeqLock* seqlock_;
TestData* data_;
base::AtomicRefCount* ready_;
@@ -67,20 +66,20 @@ class BasicSeqLockTestThread : public PlatformThread::Delegate {
#define MAYBE_ManyThreads ManyThreads
#endif
TEST(OneWriterSeqLockTest, MAYBE_ManyThreads) {
- content::OneWriterSeqLock seqlock;
- TestData data = { 0, 0, 0 };
+ device::OneWriterSeqLock seqlock;
+ TestData data = {0, 0, 0};
base::AtomicRefCount ready = 0;
ANNOTATE_BENIGN_RACE_SIZED(&data, sizeof(data), "Racey reads are discarded");
static const unsigned kNumReaderThreads = 10;
BasicSeqLockTestThread threads[kNumReaderThreads];
- PlatformThreadHandle handles[kNumReaderThreads];
+ base::PlatformThreadHandle handles[kNumReaderThreads];
for (unsigned i = 0; i < kNumReaderThreads; ++i)
threads[i].Init(&seqlock, &data, &ready);
for (unsigned i = 0; i < kNumReaderThreads; ++i)
- ASSERT_TRUE(PlatformThread::Create(0, &threads[i], &handles[i]));
+ ASSERT_TRUE(base::PlatformThread::Create(0, &threads[i], &handles[i]));
// The main thread is the writer, and the spawned are readers.
unsigned counter = 0;
@@ -94,12 +93,12 @@ TEST(OneWriterSeqLockTest, MAYBE_ManyThreads) {
if (counter == 1)
base::AtomicRefCountIncN(&ready, kNumReaderThreads);
- if (AtomicRefCountIsZero(&ready))
+ if (base::AtomicRefCountIsZero(&ready))
break;
}
for (unsigned i = 0; i < kNumReaderThreads; ++i)
- PlatformThread::Join(handles[i]);
+ base::PlatformThread::Join(handles[i]);
}
-} // namespace base
+} // namespace device
« no previous file with comments | « device/base/synchronization/one_writer_seqlock.cc ('k') | device/base/synchronization/shared_memory_seqlock_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698