OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4StdInProc Class Reference

#include <C4StdInProc.h>

Inheritance diagram for C4StdInProc:
[legend]
Collaboration diagram for C4StdInProc:
[legend]

Public Member Functions

 C4StdInProc ()
 
 ~C4StdInProc ()
 
virtual bool Execute (int iTimeout, pollfd *)
 
virtual void GetFDs (std::vector< struct pollfd > &checkfds)
 
bool ExecuteUntil (int iTimeout=-1)
 
virtual C4TimeMilliseconds GetNextTick (C4TimeMilliseconds tNow)
 
bool IsSignaled ()
 
virtual bool IsLowPriority ()
 
virtual bool IsNotify ()
 
virtual uint32_t TimerInterval ()
 

Protected Member Functions

void Changed ()
 

Detailed Description

Definition at line 22 of file C4StdInProc.h.

Constructor & Destructor Documentation

C4StdInProc::C4StdInProc ( )

Definition at line 62 of file C4StdInProc.cpp.

62 { }
C4StdInProc::~C4StdInProc ( )

Definition at line 64 of file C4StdInProc.cpp.

64 { }

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 C4StdInProc::Execute ( int  iTimeout,
pollfd *   
)
virtual

Implements StdSchedulerProc.

Definition at line 66 of file C4StdInProc.cpp.

References StdStrBuf::AppendChar(), Application, StdStrBuf::Clear(), StdStrBuf::getData(), StdStrBuf::isNull(), C4Application::OnCommand(), and C4Application::Quit().

67 {
68  // Surely not the most efficient way to do it, but we won't have to read much data anyway.
69  char c;
70  if (read(0, &c, 1) != 1)
71  {
72  Application.Quit();
73  return false;
74  }
75  if (c == '\n')
76  {
77  if (!CmdBuf.isNull())
78  {
79  Application.OnCommand(CmdBuf.getData());
80  CmdBuf.Clear();
81  }
82  }
83  else if (isprint((unsigned char)c))
84  CmdBuf.AppendChar(c);
85  return true;
86 }
const char * getData() const
Definition: StdBuf.h:450
void Clear()
Definition: StdBuf.h:474
virtual void OnCommand(const char *szCmd)
void AppendChar(char cChar)
Definition: StdBuf.h:596
virtual void Quit()
bool isNull() const
Definition: StdBuf.h:449
C4Application Application
Definition: C4Globals.cpp:44

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 C4StdInProc::GetFDs ( std::vector< struct pollfd > &  checkfds)
inlinevirtual

Reimplemented from StdSchedulerProc.

Definition at line 33 of file C4StdInProc.h.

34  {
35  pollfd pfd = { 0, POLLIN, 0 };
36  checkfds.push_back(pfd);
37  }
C4TimeMilliseconds StdSchedulerProc::GetNextTick ( C4TimeMilliseconds  tNow)
virtualinherited

Reimplemented in C4NetIOUDP, C4Network2HTTPClient, C4Network2IO, and CStdTimerProc.

Definition at line 128 of file StdScheduler.cpp.

References C4TimeMilliseconds::PositiveInfinity.

Referenced by C4Network2HTTPClient::GetNextTick().

Here is the caller graph for this function:

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
virtual uint32_t StdSchedulerProc::TimerInterval ( )
inlinevirtualinherited

Reimplemented in CStdTimerProc.

Definition at line 88 of file StdScheduler.h.

Referenced by SCHAdditions::assignAdditionForProc:.

88 { return 0; }

Here is the caller graph for this function:


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