Panda3D

trueClock.I

00001 // Filename: trueClock.I
00002 // Created by:  drose (04Jul00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 #if defined(WIN32_VC) || defined(WIN64_VC)
00017 
00018 ////////////////////////////////////////////////////////////////////
00019 //     Function: TrueClock::get_short_time, Win32 implementation
00020 //       Access: Published
00021 //  Description: 
00022 ////////////////////////////////////////////////////////////////////
00023 INLINE double TrueClock::
00024 get_short_time() {
00025   bool is_paranoid_clock = get_paranoid_clock();
00026 
00027   if (is_paranoid_clock) {
00028     _lock.acquire();
00029   }
00030 
00031   double time = get_short_raw_time();
00032 
00033   if (is_paranoid_clock) {
00034     // Check for rollforwards, rollbacks, and compensate for Speed
00035     // Gear type programs by verifying against the time of day clock.
00036     time = correct_time(time);
00037     _lock.release();
00038   }
00039 
00040   return time;
00041 }
00042 
00043 #else  // WIN32_VC
00044 
00045 ////////////////////////////////////////////////////////////////////
00046 //     Function: TrueClock::get_short_time, Posix implementation
00047 //       Access: Published
00048 //  Description: 
00049 ////////////////////////////////////////////////////////////////////
00050 INLINE double TrueClock::
00051 get_short_time() {
00052   return get_short_raw_time();
00053 }
00054 
00055 #endif  // WIN32_VC
00056 
00057 
00058 ////////////////////////////////////////////////////////////////////
00059 //     Function: TrueClock::get_error_count
00060 //       Access: Published
00061 //  Description: Returns the number of clock errors that have
00062 //               been detected.  Each time a clock error is detected,
00063 //               in which the value returned by either of the above
00064 //               methods is suspect, the value returned by this method
00065 //               will be incremented.  Applications can monitor this
00066 //               value and react, for instance, by resynchronizing
00067 //               their clocks each time this value changes.
00068 ////////////////////////////////////////////////////////////////////
00069 INLINE int TrueClock::
00070 get_error_count() const {
00071   return _error_count;
00072 }
00073 
00074 ////////////////////////////////////////////////////////////////////
00075 //     Function: TrueClock::get_global_ptr
00076 //       Access: Published, Static
00077 //  Description: Returns a pointer to the one TrueClock object in
00078 //               the world.
00079 ////////////////////////////////////////////////////////////////////
00080 INLINE TrueClock *TrueClock::
00081 get_global_ptr() {
00082   if (_global_ptr == (TrueClock *)NULL) {
00083     _global_ptr = new TrueClock;
00084   }
00085   return _global_ptr;
00086 }
00087 
00088 ////////////////////////////////////////////////////////////////////
00089 //     Function: TrueClock::Destructor
00090 //       Access: Protected
00091 //  Description: A protected destructor because no one should try to
00092 //               delete the global TrueClock.
00093 ////////////////////////////////////////////////////////////////////
00094 INLINE TrueClock::
00095 ~TrueClock() {
00096 }
 All Classes Functions Variables Enumerations