| 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 // Multi-threaded tests of ConditionVariable class. | 5 // Multi-threaded tests of ConditionVariable class. |
| 6 | 6 |
| 7 #include "base/synchronization/condition_variable.h" | 7 #include "base/synchronization/condition_variable.h" |
| 8 | 8 |
| 9 #include <time.h> | 9 #include <time.h> |
| 10 | 10 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 PLOG(ERROR) << "Could not set time of day. Run as root?"; | 218 PLOG(ERROR) << "Could not set time of day. Run as root?"; |
| 219 return; | 219 return; |
| 220 } | 220 } |
| 221 | 221 |
| 222 Lock lock; | 222 Lock lock; |
| 223 ConditionVariable cv(&lock); | 223 ConditionVariable cv(&lock); |
| 224 lock.Acquire(); | 224 lock.Acquire(); |
| 225 | 225 |
| 226 Thread thread("Helper"); | 226 Thread thread("Helper"); |
| 227 thread.Start(); | 227 thread.Start(); |
| 228 thread.task_runner()->PostTask(FROM_HERE, base::Bind(&BackInTime, &lock)); | 228 thread.task_runner()->PostTask(FROM_HERE, base::BindOnce(&BackInTime, &lock)); |
| 229 | 229 |
| 230 TimeTicks start = TimeTicks::Now(); | 230 TimeTicks start = TimeTicks::Now(); |
| 231 const TimeDelta kWaitTime = TimeDelta::FromMilliseconds(300); | 231 const TimeDelta kWaitTime = TimeDelta::FromMilliseconds(300); |
| 232 // Allow for clocking rate granularity. | 232 // Allow for clocking rate granularity. |
| 233 const TimeDelta kFudgeTime = TimeDelta::FromMilliseconds(50); | 233 const TimeDelta kFudgeTime = TimeDelta::FromMilliseconds(50); |
| 234 | 234 |
| 235 cv.TimedWait(kWaitTime + kFudgeTime); | 235 cv.TimedWait(kWaitTime + kFudgeTime); |
| 236 TimeDelta duration = TimeTicks::Now() - start; | 236 TimeDelta duration = TimeTicks::Now() - start; |
| 237 | 237 |
| 238 thread.Stop(); | 238 thread.Stop(); |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 base::AutoLock auto_lock(lock_); | 759 base::AutoLock auto_lock(lock_); |
| 760 // Send notification that we completed our "work." | 760 // Send notification that we completed our "work." |
| 761 WorkIsCompleted(thread_id); | 761 WorkIsCompleted(thread_id); |
| 762 } | 762 } |
| 763 } | 763 } |
| 764 } | 764 } |
| 765 | 765 |
| 766 } // namespace | 766 } // namespace |
| 767 | 767 |
| 768 } // namespace base | 768 } // namespace base |
| OLD | NEW |