forked from Mirrors/openclonk
StdScheduler: Make DoScheduleProcs virtual, override it in C4AbstractApp and set isInManualLoop flag around the DoScheduleProcs call so the FlushMessages() of C4AbstractApp will happen when isInManualLoop is true
parent
75f3fb2d70
commit
92186db246
|
@ -25,7 +25,7 @@ void C4AbstractApp::Run()
|
|||
ScheduleProcs();
|
||||
}
|
||||
|
||||
bool C4AbstractApp::ScheduleProcs(int iTimeout)
|
||||
bool C4AbstractApp::DoScheduleProcs(int iTimeout)
|
||||
{
|
||||
// Always fail after quit message
|
||||
if(fQuitMsgReceived)
|
||||
|
@ -34,7 +34,7 @@ bool C4AbstractApp::ScheduleProcs(int iTimeout)
|
|||
// Unfortunately, the SDL event loop needs to be polled
|
||||
FlushMessages();
|
||||
#endif
|
||||
return StdScheduler::ScheduleProcs(iTimeout);
|
||||
return StdScheduler::DoScheduleProcs(iTimeout);
|
||||
}
|
||||
|
||||
void C4Window::PerformUpdate()
|
||||
|
|
|
@ -97,7 +97,7 @@ public:
|
|||
// Gamma
|
||||
virtual bool ApplyGammaRamp(struct _GAMMARAMP &ramp, bool fForce);
|
||||
virtual bool SaveDefaultGammaRamp(struct _GAMMARAMP &ramp);
|
||||
virtual bool ScheduleProcs(int iTimeout = 1000/36);
|
||||
virtual bool DoScheduleProcs(int iTimeout);
|
||||
bool FlushMessages();
|
||||
C4Window * pWindow;
|
||||
bool fQuitMsgReceived; // if true, a quit message has been received and the application should terminate
|
||||
|
|
|
@ -132,7 +132,6 @@ C4TimeMilliseconds StdSchedulerProc::GetNextTick(C4TimeMilliseconds tNow)
|
|||
|
||||
bool StdScheduler::ScheduleProcs(int iTimeout)
|
||||
{
|
||||
isInManualLoop = true;
|
||||
// Needs at least one process to work properly
|
||||
if (!procs.size()) return false;
|
||||
|
||||
|
@ -149,8 +148,10 @@ bool StdScheduler::ScheduleProcs(int iTimeout)
|
|||
}
|
||||
}
|
||||
|
||||
bool old = isInManualLoop;
|
||||
isInManualLoop = true;
|
||||
bool res = DoScheduleProcs(iTimeout);
|
||||
isInManualLoop = false;
|
||||
isInManualLoop = old;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -246,15 +246,13 @@ public:
|
|||
// needs to be called on thread tasks for this scheduler are meant to be run on
|
||||
void StartOnCurrentThread();
|
||||
|
||||
virtual bool ScheduleProcs(int iTimeout = -1);
|
||||
bool ScheduleProcs(int iTimeout = 1000/36);
|
||||
void UnBlock();
|
||||
|
||||
protected:
|
||||
// overridable
|
||||
virtual void OnError(StdSchedulerProc *) { }
|
||||
|
||||
private:
|
||||
bool DoScheduleProcs(int iTimeout);
|
||||
virtual bool DoScheduleProcs(int iTimeout);
|
||||
};
|
||||
|
||||
// A simple process scheduler thread
|
||||
|
|
Loading…
Reference in New Issue