| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/platform_thread.h" | 6 #include "base/platform_thread.h" |
| 7 #include "base/shared_memory.h" | 7 #include "base/shared_memory.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 static const int kNumThreads = 5; | 10 static const int kNumThreads = 5; |
| 11 | 11 |
| 12 namespace base { |
| 13 |
| 12 namespace { | 14 namespace { |
| 13 | 15 |
| 14 class SharedMemoryTest : public testing::Test { | |
| 15 }; | |
| 16 | |
| 17 // Each thread will open the shared memory. Each thread will take a different 4 | 16 // Each thread will open the shared memory. Each thread will take a different 4 |
| 18 // byte int pointer, and keep changing it, with some small pauses in between. | 17 // byte int pointer, and keep changing it, with some small pauses in between. |
| 19 // Verify that each thread's value in the shared memory is always correct. | 18 // Verify that each thread's value in the shared memory is always correct. |
| 20 class MultipleThreadMain : public PlatformThread::Delegate { | 19 class MultipleThreadMain : public PlatformThread::Delegate { |
| 21 public: | 20 public: |
| 22 explicit MultipleThreadMain(int16 id) : id_(id) {} | 21 explicit MultipleThreadMain(int16 id) : id_(id) {} |
| 23 ~MultipleThreadMain() {} | 22 ~MultipleThreadMain() {} |
| 24 | 23 |
| 25 // PlatformThread::Delegate interface. | 24 // PlatformThread::Delegate interface. |
| 26 void ThreadMain() { | 25 void ThreadMain() { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 thread_handles[index] = pth; | 173 thread_handles[index] = pth; |
| 175 } | 174 } |
| 176 | 175 |
| 177 // Wait for the threads to finish. | 176 // Wait for the threads to finish. |
| 178 for (int index = 0; index < kNumThreads; ++index) { | 177 for (int index = 0; index < kNumThreads; ++index) { |
| 179 PlatformThread::Join(thread_handles[index]); | 178 PlatformThread::Join(thread_handles[index]); |
| 180 delete thread_delegates[index]; | 179 delete thread_delegates[index]; |
| 181 } | 180 } |
| 182 } | 181 } |
| 183 #endif | 182 #endif |
| 183 |
| 184 } // namespace base |
| OLD | NEW |