Game Development Reference
In-Depth Information
Round Robin Scheduling Gone Bad
This system was used extensively to control the login servers of UltimaOnline.
When it was initially deployed, customer service began to receive complaints
that some users were waiting more than five minutes for the login process to
finish, and that didn
t agree with the login server metrics, which measured
over 2,000 logins per minute and an average login time of 15 seconds or so.
The problem was identified after a little digging. I had bailed early from serving
all the processes in the list in an attempt to poll network sockets and database
activity, and in so doing, I left a few processes at the end of the list completely
out in the cold.
'
Very Simple Process Example: DelayProcess
A very simple example of a useful process using this cooperative design is a delay
process. This process is useful for inserting timed delays, such as the fuse on an
explosive. Here
'
s how it works:
class DelayProcess : public Process
{
unsigned long m_timeToDelay;
unsigned long m_timeDelayedSoFar;
public:
explicit DelayProcess(unsigned long timeToDelay);
protected:
virtual void OnUpdate(unsigned long deltaMs);
};
DelayProcess::DelayProcess(unsigned long timeToDelay)
{
m_timeToDelay = timeToDelay;
m_timeDelayedSoFar = 0;
}
void DelayProcess::OnUpdate(unsigned long deltaMs)
{
m_timeDelayedSoFar += deltaMs;
if (m_timeDelayedSoFar >= m_timeToDelay)
Succeed();
}
Here
'
s how you create an instance of DelayProcess :
StrongProcessPtr pDelay(new DelayProcess(3000)); // delay for 3 seconds
processManager.AttachProcess(pDelay);
 
 
Search WWH ::




Custom Search