strieder
Initiate
I've been playing around with ServeUO a bit for the first time trying to understand more about how it works. Please correct me if i'm wrong but my understanding so far is I can see there is the main method that contains a while loop responsible for calling a few important methods that essentially "progress" the world:
Perhaps my biggest area of not understanding is around the kind of helper thread for time keeping and the Timer.Slice() method. One key thing I can see is that sometimes the main thread is taking a very long time to execute the Timer.Slice() method. I can see some synchronisation via locking between this helper thread and the main thread and this is one place they seem to clash. What exactly is Timer.Slice() doing? Does it particularly need to be a part of the main method or could there be any room to offload the processing that the main thread is doing in Timer.Slice() to the helper thread?
- Mobile/ItemProcessDeltaQueue(); processing changes in the worlds objects like movement, hp updates, death, spawn etc.
- Pushing packets to clients via NetState.FlushAll()
- Timer.Slice() seems to be incrementing the servers internal method of keeping time; its "clock"; for when events will happen in the future e.g. curse expires from target.
Perhaps my biggest area of not understanding is around the kind of helper thread for time keeping and the Timer.Slice() method. One key thing I can see is that sometimes the main thread is taking a very long time to execute the Timer.Slice() method. I can see some synchronisation via locking between this helper thread and the main thread and this is one place they seem to clash. What exactly is Timer.Slice() doing? Does it particularly need to be a part of the main method or could there be any room to offload the processing that the main thread is doing in Timer.Slice() to the helper thread?
while (!Closing)
{
_Signal.WaitOne();
Mobile.ProcessDeltaQueue();
Item.ProcessDeltaQueue();
Timer.Slice();
messagePump.Slice();
NetState.FlushAll();
NetState.ProcessDisposedQueue();
if (Slice != null)
{
Slice();
}
if (sample++ % sampleInterval != 0)
{
continue;
}
now = TickCount;
_CyclesPerSecond[_CycleIndex++ % _CyclesPerSecond.Length] = ticksPerSecond / (now - last);
last = now;
}
{
_Signal.WaitOne();
Mobile.ProcessDeltaQueue();
Item.ProcessDeltaQueue();
Timer.Slice();
messagePump.Slice();
NetState.FlushAll();
NetState.ProcessDisposedQueue();
if (Slice != null)
{
Slice();
}
if (sample++ % sampleInterval != 0)
{
continue;
}
now = TickCount;
_CyclesPerSecond[_CycleIndex++ % _CyclesPerSecond.Length] = ticksPerSecond / (now - last);
last = now;
}