| 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 "base/synchronization/waitable_event.h" | 5 #include "base/synchronization/waitable_event.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 TimeTicks start = TimeTicks::Now(); | 153 TimeTicks start = TimeTicks::Now(); |
| 154 PlatformThread::Create(0, &signaler, &thread); | 154 PlatformThread::Create(0, &signaler, &thread); |
| 155 | 155 |
| 156 ev->TimedWait(TimeDelta::Max()); | 156 ev->TimedWait(TimeDelta::Max()); |
| 157 EXPECT_GE(TimeTicks::Now() - start, thread_delay); | 157 EXPECT_GE(TimeTicks::Now() - start, thread_delay); |
| 158 delete ev; | 158 delete ev; |
| 159 | 159 |
| 160 PlatformThread::Join(thread); | 160 PlatformThread::Join(thread); |
| 161 } | 161 } |
| 162 | 162 |
| 163 // Tests that a sub-ms TimedWait doesn't time out promptly. |
| 164 TEST(WaitableEventTest, SubMsTimedWait) { |
| 165 WaitableEvent ev(WaitableEvent::ResetPolicy::AUTOMATIC, |
| 166 WaitableEvent::InitialState::NOT_SIGNALED); |
| 167 |
| 168 TimeDelta delay = TimeDelta::FromMicroseconds(900); |
| 169 TimeTicks start = TimeTicks::Now(); |
| 170 ev.TimedWait(delay); |
| 171 EXPECT_GE(TimeTicks::Now() - start, delay); |
| 172 } |
| 173 |
| 163 } // namespace base | 174 } // namespace base |
| OLD | NEW |