OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Network2::InitialConnect Class Reference

#include <C4Network2.h>

Inheritance diagram for C4Network2::InitialConnect:
[legend]
Collaboration diagram for C4Network2::InitialConnect:
[legend]

Public Member Functions

 InitialConnect (const std::vector< C4Network2Address > &Addrs, const C4ClientCore &HostCore, const char *Password)
 
 ~InitialConnect ()
 
virtual bool Execute (int, pollfd *) override
 

Protected Member Functions

void Set ()
 
void SetDelay (uint32_t inDelay)
 
bool CheckAndReset ()
 
virtual C4TimeMilliseconds GetNextTick (C4TimeMilliseconds tNow)
 
virtual uint32_t TimerInterval ()
 
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 369 of file C4Network2.h.

Constructor & Destructor Documentation

C4Network2::InitialConnect::InitialConnect ( const std::vector< C4Network2Address > &  Addrs,
const C4ClientCore HostCore,
const char *  Password 
)

Definition at line 336 of file C4Network2.cpp.

References StdScheduler::Add(), and Application.

337  : CStdTimerProc(DELAY), Addrs(Addrs), CurrentAddr(this->Addrs.cbegin()),
338  HostCore(HostCore), Password(Password)
339 {
340  Application.Add(this);
341 }
void Add(StdSchedulerProc *pProc)
CStdTimerProc(uint32_t iDelay)
Definition: StdScheduler.h:98
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

C4Network2::InitialConnect::~InitialConnect ( )

Definition at line 343 of file C4Network2.cpp.

344 {
345  Done();
346 }

Member Function Documentation

void StdSchedulerProc::Changed ( )
protectedinherited

Definition at line 121 of file StdScheduler.cpp.

References s.

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

122 {
123  auto s = scheduler;
124  if (s)
125  s->Changed(this);
126 }
#define s

Here is the caller graph for this function:

bool CStdTimerProc::CheckAndReset ( )
inlineinherited

Definition at line 111 of file StdScheduler.h.

References C4TimeMilliseconds::Now().

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Network2::InitialConnect::Execute ( int  ,
pollfd *   
)
overridevirtual

Implements StdSchedulerProc.

Definition at line 348 of file C4Network2.cpp.

References CStdTimerProc::CheckAndReset().

349 {
350  if (CheckAndReset())
351  TryNext();
352  return true;
353 }
bool CheckAndReset()
Definition: StdScheduler.h:111

Here is the call graph for this function:

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

Definition at line 46 of file StdScheduler.cpp.

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

Referenced by main().

47 {
48  // Infinite?
49  if (iTimeout < 0)
50  for (;;)
51  if (!Execute())
52  return false;
53  // Calculate endpoint
54  C4TimeMilliseconds tStopTime = C4TimeMilliseconds::Now() + iTimeout;
55  for (;;)
56  {
57  // Call execute with given timeout
58  if (!Execute(std::max(iTimeout, 0)))
59  return false;
60  // Calculate timeout
62  if (tTime >= tStopTime)
63  break;
64  iTimeout = tStopTime - tTime;
65  }
66  // All ok.
67  return true;
68 }
virtual bool Execute(int iTimeout=-1, pollfd *readyfds=0)=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 76 of file StdScheduler.h.

Referenced by SCHNotify::registerAt:.

76 { }

Here is the caller graph for this function:

virtual C4TimeMilliseconds CStdTimerProc::GetNextTick ( C4TimeMilliseconds  tNow)
inlinevirtualinherited

Reimplemented from StdSchedulerProc.

Definition at line 122 of file StdScheduler.h.

123  {
124  return tLastTimer + iDelay;
125  }
virtual bool StdSchedulerProc::IsLowPriority ( )
inlinevirtualinherited

Definition at line 86 of file StdScheduler.h.

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

Reimplemented in C4NetIO, and CStdNotifyProc.

Definition at line 87 of file StdScheduler.h.

Referenced by SCHAdditions::assignAdditionForProc:.

87 { return false; }

Here is the caller graph for this function:

bool StdSchedulerProc::IsSignaled ( )
inherited
void CStdTimerProc::Set ( )
inlineinherited

Definition at line 106 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 110 of file StdScheduler.h.

References StdSchedulerProc::Changed().

110 { iDelay = inDelay; Changed(); }

Here is the call graph for this function:

virtual uint32_t CStdTimerProc::TimerInterval ( )
inlinevirtualinherited

Reimplemented from StdSchedulerProc.

Definition at line 126 of file StdScheduler.h.

126 { return iDelay; }

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