| 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 | 5 |
| 6 // Windows Timer Primer | 6 // Windows Timer Primer |
| 7 // | 7 // |
| 8 // A good article: http://www.ddj.com/windows/184416651 | 8 // A good article: http://www.ddj.com/windows/184416651 |
| 9 // A good mozilla bug: http://bugzilla.mozilla.org/show_bug.cgi?id=363258 | 9 // A good mozilla bug: http://bugzilla.mozilla.org/show_bug.cgi?id=363258 |
| 10 // | 10 // |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 // (3) System time. The system time provides a low-resolution (from ~1 to ~15.6 | 373 // (3) System time. The system time provides a low-resolution (from ~1 to ~15.6 |
| 374 // milliseconds) time stamp but is comparatively less expensive to retrieve and | 374 // milliseconds) time stamp but is comparatively less expensive to retrieve and |
| 375 // more reliable. Time::EnableHighResolutionTimer() and | 375 // more reliable. Time::EnableHighResolutionTimer() and |
| 376 // Time::ActivateHighResolutionTimer() can be called to alter the resolution of | 376 // Time::ActivateHighResolutionTimer() can be called to alter the resolution of |
| 377 // this timer; and also other Windows applications can alter it, affecting this | 377 // this timer; and also other Windows applications can alter it, affecting this |
| 378 // one. | 378 // one. |
| 379 | 379 |
| 380 using NowFunction = TimeDelta (*)(void); | 380 using NowFunction = TimeDelta (*)(void); |
| 381 | 381 |
| 382 TimeDelta InitialNowFunction(); | 382 TimeDelta InitialNowFunction(); |
| 383 TimeDelta InitialSystemTraceNowFunction(); | |
| 384 | 383 |
| 385 // See "threading notes" in InitializeNowFunctionPointer() for details on how | 384 // See "threading notes" in InitializeNowFunctionPointer() for details on how |
| 386 // concurrent reads/writes to these globals has been made safe. | 385 // concurrent reads/writes to these globals has been made safe. |
| 387 NowFunction g_now_function = &InitialNowFunction; | 386 NowFunction g_now_function = &InitialNowFunction; |
| 388 int64 g_qpc_ticks_per_second = 0; | 387 int64 g_qpc_ticks_per_second = 0; |
| 389 | 388 |
| 390 // As of January 2015, use of <atomic> is forbidden in Chromium code. This is | 389 // As of January 2015, use of <atomic> is forbidden in Chromium code. This is |
| 391 // what std::atomic_thread_fence does on Windows on all Intel architectures when | 390 // what std::atomic_thread_fence does on Windows on all Intel architectures when |
| 392 // the memory_order argument is anything but std::memory_order_seq_cst: | 391 // the memory_order argument is anything but std::memory_order_seq_cst: |
| 393 #define ATOMIC_THREAD_FENCE(memory_order) _ReadWriteBarrier(); | 392 #define ATOMIC_THREAD_FENCE(memory_order) _ReadWriteBarrier(); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 TimeTicks TimeTicks::FromQPCValue(LONGLONG qpc_value) { | 517 TimeTicks TimeTicks::FromQPCValue(LONGLONG qpc_value) { |
| 519 return TimeTicks() + QPCValueToTimeDelta(qpc_value); | 518 return TimeTicks() + QPCValueToTimeDelta(qpc_value); |
| 520 } | 519 } |
| 521 | 520 |
| 522 // TimeDelta ------------------------------------------------------------------ | 521 // TimeDelta ------------------------------------------------------------------ |
| 523 | 522 |
| 524 // static | 523 // static |
| 525 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { | 524 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { |
| 526 return QPCValueToTimeDelta(qpc_value); | 525 return QPCValueToTimeDelta(qpc_value); |
| 527 } | 526 } |
| OLD | NEW |