TrueReality  v0.1.1912
Timer.cpp
Go to the documentation of this file.
1 /*
2 * True Reality Open Source Game and Simulation Engine
3 * Copyright © 2021 Acid Rain Studios LLC
4 *
5 * This library is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License as published by the Free
7 * Software Foundation; either version 3.0 of the License, or (at your option)
8 * any later version.
9 *
10 * This library is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this library; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * @author Maxim Serebrennik
20 */
21 
22 #include <trUtil/Timer.h>
23 
24 #include <OpenThreads/Thread>
25 
26 namespace trUtil
27 {
28 
30  void AppSleep(unsigned int milliseconds)
31  {
32  if (milliseconds == 0)
33  {
34  OpenThreads::Thread::YieldCurrentThread();
35  }
36  else
37  {
38  OpenThreads::Thread::microSleep((milliseconds) * 1000);
39  }
40  }
41 
44 
46  {
47 
48  }
49 
52  {
53 
54  }
55 
58  {
59  static Timer sTimer;
60  return &sTimer;
61  }
62 
65  {
66  mTimer.setStartTick(t);
68  mNewTicks = t;
69  mCustomTicks = (mNewTicks - mTimer.tick());
70  }
71 }
72 
void TR_UTIL_EXPORT AppSleep(unsigned int milliseconds)
Puts the current application thread to sleep for a given number of milliseconds.
Definition: Timer.cpp:30
Timer class is used for measuring elapsed time or time between two points.
Definition: Timer.h:65
static const Timer * Instance()
Creates and returns a global timer.
Definition: Timer.cpp:57
Timer()
Default constructor.
Definition: Timer.cpp:45
osg::Timer mTimer
Definition: Timer.h:235
void SetStartTick()
Set the start tick.
Definition: Timer.h:112
Namespace that holds various utility classes for the engine.
Definition: SmrtPtr.h:208
TimeTicks mNewTicks
Definition: Timer.h:237
TimeTicks mOldTicks
Definition: Timer.h:236
~Timer()
Destructor.
Definition: Timer.cpp:51
TimeTicks mCustomTicks
Definition: Timer.h:238
unsigned long long TimeTicks
64bit Integer to hold the Timers time ticks.
Definition: Timer.h:42