OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4GameSec1Timer Class Reference
Inheritance diagram for C4GameSec1Timer:
[legend]
Collaboration diagram for C4GameSec1Timer:
[legend]

Public Member Functions

 C4GameSec1Timer ()
 
 ~C4GameSec1Timer () override
 
void OnSec1Timer () override
 

Protected Member Functions

bool Execute (int, pollfd *) override
 
void Set ()
 
void SetDelay (uint32_t inDelay)
 
bool CheckAndReset ()
 
C4TimeMilliseconds GetNextTick (C4TimeMilliseconds tNow) override
 
uint32_t TimerInterval () override
 
void Changed ()
 
bool ExecuteUntil (int iTimeout=-1)
 
virtual void GetFDs (std::vector< struct pollfd > &)
 
bool IsSignaled ()
 
virtual bool IsLowPriority ()
 
virtual bool IsNotify ()
 

Detailed Description

Definition at line 83 of file C4Game.cpp.

Constructor & Destructor Documentation

C4GameSec1Timer::C4GameSec1Timer ( )
inline

Definition at line 86 of file C4Game.cpp.

References StdScheduler::Add(), and Application.

86 { Application.Add(this); }
void Add(StdSchedulerProc *pProc)
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

C4GameSec1Timer::~C4GameSec1Timer ( )
inlineoverride

Definition at line 87 of file C4Game.cpp.

References Application, and StdScheduler::Remove().

87 { Application.Remove(this); }
void Remove(StdSchedulerProc *pProc)
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

Member Function Documentation

void StdSchedulerProc::Changed ( )
protectedinherited

Definition at line 108 of file StdScheduler.cpp.

References s.

Referenced by C4NetIOTCP::Accept(), C4NetIOTCP::AddConnectWait(), C4NetIOUDP::AddPeer(), C4NetIOTCP::Listen(), and CStdTimerProc::SetDelay().

109 {
110  auto s = scheduler;
111  if (s)
112  s->Changed(this);
113 }
#define s

Here is the caller graph for this function:

bool CStdTimerProc::CheckAndReset ( )
inlineinherited

Definition at line 107 of file StdScheduler.h.

References C4TimeMilliseconds::Now().

Referenced by C4ApplicationSec1Timer::Execute(), and C4Network2::InitialConnect::Execute().

108  {
110  if (tTime < tLastTimer + iDelay) return false;
111  // Compensate light drifting
112  int32_t iDrift = tTime - (tLastTimer + iDelay); // a positive time difference because of above check
113  tLastTimer = tTime - std::min(iDrift, (int32_t) iDelay / 2);
114  return true;
115  }
static C4TimeMilliseconds Now()

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ApplicationSec1Timer::Execute ( int  ,
pollfd *   
)
inlineoverrideprotectedvirtualinherited

Implements StdSchedulerProc.

Definition at line 131 of file StdScheduler.h.

References CStdTimerProc::CheckAndReset(), and C4ApplicationSec1Timer::OnSec1Timer().

132  {
133  if (CheckAndReset())
134  OnSec1Timer();
135  return true;
136  }
bool CheckAndReset()
Definition: StdScheduler.h:107
virtual void OnSec1Timer()=0

Here is the call graph for this function:

bool StdSchedulerProc::ExecuteUntil ( int  iTimeout = -1)
inherited

Definition at line 33 of file StdScheduler.cpp.

References StdSchedulerProc::Execute(), and C4TimeMilliseconds::Now().

Referenced by main().

34 {
35  // Infinite?
36  if (iTimeout < 0)
37  for (;;)
38  if (!Execute())
39  return false;
40  // Calculate endpoint
41  C4TimeMilliseconds tStopTime = C4TimeMilliseconds::Now() + iTimeout;
42  for (;;)
43  {
44  // Call execute with given timeout
45  if (!Execute(std::max(iTimeout, 0)))
46  return false;
47  // Calculate timeout
49  if (tTime >= tStopTime)
50  break;
51  iTimeout = tStopTime - tTime;
52  }
53  // All ok.
54  return true;
55 }
virtual bool Execute(int iTimeout=-1, pollfd *readyfds=nullptr)=0
static C4TimeMilliseconds Now()

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void StdSchedulerProc::GetFDs ( std::vector< struct pollfd > &  )
inlinevirtualinherited

Reimplemented in C4NetIOSimpleUDP, C4NetIOTCP, CStdNotifyProc, C4FileMonitor, and C4StdInProc.

Definition at line 72 of file StdScheduler.h.

Referenced by SCHNotify::registerAt:.

72 { }

Here is the caller graph for this function:

C4TimeMilliseconds CStdTimerProc::GetNextTick ( C4TimeMilliseconds  tNow)
inlineoverridevirtualinherited

Reimplemented from StdSchedulerProc.

Definition at line 118 of file StdScheduler.h.

119  {
120  return tLastTimer + iDelay;
121  }
virtual bool StdSchedulerProc::IsLowPriority ( )
inlinevirtualinherited

Definition at line 82 of file StdScheduler.h.

82 { return false; }
virtual bool StdSchedulerProc::IsNotify ( )
inlinevirtualinherited

Reimplemented in C4NetIO, and CStdNotifyProc.

Definition at line 83 of file StdScheduler.h.

Referenced by SCHAdditions::assignAdditionForProc:.

83 { return false; }

Here is the caller graph for this function:

bool StdSchedulerProc::IsSignaled ( )
inherited
void C4GameSec1Timer::OnSec1Timer ( )
overridevirtual

Implements C4ApplicationSec1Timer.

Definition at line 1437 of file C4Game.cpp.

References C4Game::cFPS, C4Game::FPS, Game, C4Game::Time, and C4Game::TimeGo.

1438 {
1439  // updates the game clock
1440  if (Game.TimeGo) { Game.Time++; Game.TimeGo = false; }
1441  Game.FPS=Game.cFPS; Game.cFPS=0;
1442 }
C4Game Game
Definition: C4Globals.cpp:52
int32_t FPS
Definition: C4Game.h:111
int32_t Time
Definition: C4Game.h:131
int32_t cFPS
Definition: C4Game.h:111
bool TimeGo
Definition: C4Game.h:130
void CStdTimerProc::Set ( )
inlineinherited

Definition at line 102 of file StdScheduler.h.

References C4TimeMilliseconds::NegativeInfinity.

Referenced by CStdTimerProc::~CStdTimerProc().

Here is the caller graph for this function:

void CStdTimerProc::SetDelay ( uint32_t  inDelay)
inlineinherited

Definition at line 106 of file StdScheduler.h.

References StdSchedulerProc::Changed().

106 { iDelay = inDelay; Changed(); }

Here is the call graph for this function:

uint32_t CStdTimerProc::TimerInterval ( )
inlineoverridevirtualinherited

Reimplemented from StdSchedulerProc.

Definition at line 122 of file StdScheduler.h.

122 { return iDelay; }

The documentation for this class was generated from the following file: