Panda3D

Loading...
Searching...
No Matches
trueClock.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file trueClock.I
10 * @author drose
11 * @date 2000-07-04
12 */
13
14#if defined(WIN32_VC) || defined(WIN64_VC)
15
16/**
17 *
18 */
19INLINE double TrueClock::
20get_short_time() {
21 bool is_paranoid_clock = get_paranoid_clock();
22
23 if (is_paranoid_clock) {
24 _lock.lock();
25 }
26
27 double time = get_short_raw_time();
28
29 if (is_paranoid_clock) {
30 // Check for rollforwards, rollbacks, and compensate for Speed Gear type
31 // programs by verifying against the time of day clock.
32 time = correct_time(time);
33 _lock.unlock();
34 }
35
36 return time;
37}
38
39#else // WIN32_VC
40
41/**
42 *
43 */
44INLINE double TrueClock::
45get_short_time() {
46 return get_short_raw_time();
47}
48
49#endif // WIN32_VC
50
51
52/**
53 * Returns the number of clock errors that have been detected. Each time a
54 * clock error is detected, in which the value returned by either of the above
55 * methods is suspect, the value returned by this method will be incremented.
56 * Applications can monitor this value and react, for instance, by
57 * resynchronizing their clocks each time this value changes.
58 */
59INLINE int TrueClock::
60 get_error_count() const {
61 return _error_count;
62}
63
64/**
65 * Returns a pointer to the one TrueClock object in the world.
66 */
67INLINE TrueClock *TrueClock::
68 get_global_ptr() {
69 if (_global_ptr == nullptr) {
70 _global_ptr = new TrueClock;
71 }
72 return _global_ptr;
73}
74
75/**
76 * A protected destructor because no one should try to delete the global
77 * TrueClock.
78 */
79INLINE TrueClock::
80~TrueClock() {
81}
TrueClock::get_error_count
get_error_count
Returns the number of clock errors that have been detected.
Definition trueClock.h:53
TrueClock::get_global_ptr
static TrueClock * get_global_ptr()
Returns a pointer to the one TrueClock object in the world.
Definition trueClock.I:68