main loop and timer efficiency
This commit is contained in:
parent
0889404d83
commit
5f07f81fe1
8 changed files with 29 additions and 7 deletions
|
|
@ -2848,6 +2848,8 @@ namespace Server
|
||||||
|
|
||||||
m_DeltaQueue.Add( this );
|
m_DeltaQueue.Add( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Core.Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemDelta( ItemDelta flags )
|
public void RemDelta( ItemDelta flags )
|
||||||
|
|
|
||||||
|
|
@ -330,6 +330,9 @@ namespace Server
|
||||||
Console.WriteLine( "done" );
|
Console.WriteLine( "done" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static AutoResetEvent m_Signal = new AutoResetEvent( true );
|
||||||
|
public static void Set() { m_Signal.Set(); }
|
||||||
|
|
||||||
public static void Main( string[] args )
|
public static void Main( string[] args )
|
||||||
{
|
{
|
||||||
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler( CurrentDomain_UnhandledException );
|
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler( CurrentDomain_UnhandledException );
|
||||||
|
|
@ -439,7 +442,7 @@ namespace Server
|
||||||
|
|
||||||
while( !m_Closing )
|
while( !m_Closing )
|
||||||
{
|
{
|
||||||
Thread.Sleep( m_MultiProcessor ? 0 : 1 );
|
m_Signal.WaitOne();
|
||||||
|
|
||||||
Mobile.ProcessDeltaQueue();
|
Mobile.ProcessDeltaQueue();
|
||||||
Item.ProcessDeltaQueue();
|
Item.ProcessDeltaQueue();
|
||||||
|
|
|
||||||
|
|
@ -9642,6 +9642,8 @@ namespace Server
|
||||||
|
|
||||||
m_DeltaQueue.Enqueue( this );
|
m_DeltaQueue.Enqueue( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Core.Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Direction GetDirectionTo( int x, int y )
|
public Direction GetDirectionTo( int x, int y )
|
||||||
|
|
|
||||||
|
|
@ -153,6 +153,8 @@ namespace Server.Network
|
||||||
{
|
{
|
||||||
IAsyncResult res = listener.BeginAccept( m_OnAccept, listener );
|
IAsyncResult res = listener.BeginAccept( m_OnAccept, listener );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Core.Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Socket[] Slice()
|
public Socket[] Slice()
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,8 @@ namespace Server.Network
|
||||||
{
|
{
|
||||||
lock ( this )
|
lock ( this )
|
||||||
m_Queue.Enqueue( ns );
|
m_Queue.Enqueue( ns );
|
||||||
|
|
||||||
|
Core.Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Slice()
|
public void Slice()
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Server {
|
namespace Server {
|
||||||
public class BinaryMemoryWriter : BinaryFileWriter {
|
public sealed class BinaryMemoryWriter : BinaryFileWriter {
|
||||||
private MemoryStream stream;
|
private MemoryStream stream;
|
||||||
|
|
||||||
protected override int BufferSize {
|
protected override int BufferSize {
|
||||||
|
|
|
||||||
|
|
@ -789,7 +789,7 @@ namespace Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BinaryFileReader : GenericReader
|
public sealed class BinaryFileReader : GenericReader
|
||||||
{
|
{
|
||||||
private BinaryReader m_File;
|
private BinaryReader m_File;
|
||||||
|
|
||||||
|
|
@ -1144,7 +1144,7 @@ namespace Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AsyncWriter : GenericWriter
|
public sealed class AsyncWriter : GenericWriter
|
||||||
{
|
{
|
||||||
private static int m_ThreadCount = 0;
|
private static int m_ThreadCount = 0;
|
||||||
public static int ThreadCount { get { return m_ThreadCount; } }
|
public static int ThreadCount { get { return m_ThreadCount; } }
|
||||||
|
|
|
||||||
|
|
@ -359,6 +359,7 @@ namespace Server
|
||||||
public static void Change( Timer t, int newIndex, bool isAdd )
|
public static void Change( Timer t, int newIndex, bool isAdd )
|
||||||
{
|
{
|
||||||
m_ChangeQueue.Enqueue( TimerChangeEntry.GetInstance( t, newIndex, isAdd ) );
|
m_ChangeQueue.Enqueue( TimerChangeEntry.GetInstance( t, newIndex, isAdd ) );
|
||||||
|
m_Signal.Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddTimer( Timer t )
|
public static void AddTimer( Timer t )
|
||||||
|
|
@ -407,18 +408,23 @@ namespace Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static AutoResetEvent m_Signal = new AutoResetEvent( true );
|
||||||
|
|
||||||
public void TimerMain()
|
public void TimerMain()
|
||||||
{
|
{
|
||||||
DateTime now;
|
DateTime now;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
bool loaded;
|
||||||
|
|
||||||
while ( !Core.Closing )
|
while ( !Core.Closing )
|
||||||
{
|
{
|
||||||
Thread.Sleep( 10 );
|
m_Signal.WaitOne( 10, false );
|
||||||
|
|
||||||
ProcessChangeQueue();
|
ProcessChangeQueue();
|
||||||
|
|
||||||
for (i=0;i<m_Timers.Length;i++)
|
loaded = false;
|
||||||
|
|
||||||
|
for ( i = 0; i < m_Timers.Length; i++)
|
||||||
{
|
{
|
||||||
now = DateTime.Now;
|
now = DateTime.Now;
|
||||||
if ( now < m_NextPriorities[i] )
|
if ( now < m_NextPriorities[i] )
|
||||||
|
|
@ -426,7 +432,7 @@ namespace Server
|
||||||
|
|
||||||
m_NextPriorities[i] = now + m_PriorityDelays[i];
|
m_NextPriorities[i] = now + m_PriorityDelays[i];
|
||||||
|
|
||||||
for (j=0;j< m_Timers[i].Count;j++)
|
for ( j = 0; j < m_Timers[i].Count; j++)
|
||||||
{
|
{
|
||||||
Timer t = m_Timers[i][j];
|
Timer t = m_Timers[i][j];
|
||||||
|
|
||||||
|
|
@ -436,6 +442,8 @@ namespace Server
|
||||||
|
|
||||||
lock ( m_Queue )
|
lock ( m_Queue )
|
||||||
m_Queue.Enqueue( t );
|
m_Queue.Enqueue( t );
|
||||||
|
|
||||||
|
loaded = true;
|
||||||
|
|
||||||
if ( t.m_Count != 0 && (++t.m_Index >= t.m_Count) )
|
if ( t.m_Count != 0 && (++t.m_Index >= t.m_Count) )
|
||||||
{
|
{
|
||||||
|
|
@ -448,6 +456,9 @@ namespace Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( loaded )
|
||||||
|
Core.Set();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue