| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Tests of basic thread functions --------------------------------------------- | 68 // Tests of basic thread functions --------------------------------------------- |
| 69 | 69 |
| 70 namespace { | 70 namespace { |
| 71 | 71 |
| 72 class FunctionTestThread : public PlatformThread::Delegate { | 72 class FunctionTestThread : public PlatformThread::Delegate { |
| 73 public: | 73 public: |
| 74 FunctionTestThread() | 74 FunctionTestThread() |
| 75 : thread_id_(kInvalidThreadId), | 75 : thread_id_(kInvalidThreadId), |
| 76 termination_ready_(true, false), | 76 termination_ready_(WaitableEvent::ResetPolicy::MANUAL, |
| 77 terminate_thread_(true, false), | 77 WaitableEvent::InitialState::NOT_SIGNALED), |
| 78 terminate_thread_(WaitableEvent::ResetPolicy::MANUAL, |
| 79 WaitableEvent::InitialState::NOT_SIGNALED), |
| 78 done_(false) {} | 80 done_(false) {} |
| 79 ~FunctionTestThread() override { | 81 ~FunctionTestThread() override { |
| 80 EXPECT_TRUE(terminate_thread_.IsSignaled()) | 82 EXPECT_TRUE(terminate_thread_.IsSignaled()) |
| 81 << "Need to mark thread for termination and join the underlying thread " | 83 << "Need to mark thread for termination and join the underlying thread " |
| 82 << "before destroying a FunctionTestThread as it owns the " | 84 << "before destroying a FunctionTestThread as it owns the " |
| 83 << "WaitableEvent blocking the underlying thread's main."; | 85 << "WaitableEvent blocking the underlying thread's main."; |
| 84 } | 86 } |
| 85 | 87 |
| 86 // Grabs |thread_id_|, runs an optional test on that thread, signals | 88 // Grabs |thread_id_|, runs an optional test on that thread, signals |
| 87 // |termination_ready_|, and then waits for |terminate_thread_| to be | 89 // |termination_ready_|, and then waits for |terminate_thread_| to be |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 EXPECT_EQ(ThreadPriority::DISPLAY, | 328 EXPECT_EQ(ThreadPriority::DISPLAY, |
| 327 NiceValueToThreadPriority(kRealtimeAudioNiceValue + 1)); | 329 NiceValueToThreadPriority(kRealtimeAudioNiceValue + 1)); |
| 328 EXPECT_EQ(ThreadPriority::REALTIME_AUDIO, | 330 EXPECT_EQ(ThreadPriority::REALTIME_AUDIO, |
| 329 NiceValueToThreadPriority(kRealtimeAudioNiceValue)); | 331 NiceValueToThreadPriority(kRealtimeAudioNiceValue)); |
| 330 EXPECT_EQ(ThreadPriority::REALTIME_AUDIO, | 332 EXPECT_EQ(ThreadPriority::REALTIME_AUDIO, |
| 331 NiceValueToThreadPriority(kLowestNiceValue)); | 333 NiceValueToThreadPriority(kLowestNiceValue)); |
| 332 } | 334 } |
| 333 #endif | 335 #endif |
| 334 | 336 |
| 335 } // namespace base | 337 } // namespace base |
| OLD | NEW |