fix(core): Adds Hashed & Hierarchical Timer Wheel (#655)

- Removes TimerPriority
- Removes TimerThread
- Adds a [Hashed & Hierarchical Timer Wheel](http://www.cs.columbia.edu/~nahum/w6998/papers/ton97-timing-wheels.pdf)
This commit is contained in:
Kamron Batman 2021-07-11 22:42:06 -07:00 • committed by GitHub
parent b99d520019
commit fb915992dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
138 changed files with 468 additions and 802 deletions

View file

@ -3022,8 +3022,6 @@ namespace Server.Mobiles
m_Owner = owner;
m_Owner.m_NextDetectHidden = Core.TickCount;
Priority = TimerPriority.FiftyMS;
}
protected override void OnTick()

View file

@ -262,7 +262,6 @@ namespace Server.Mobiles
{
m_Mobile = m;
m_Mod = mod;
Priority = TimerPriority.TwoFiftyMS;
}
public void DoExpire()

View file

@ -73,14 +73,14 @@ namespace Server.Mobiles
var rand = Utility.Random(527);
/*
500 527 No Hue Color 94.88% 0
10 527 Green 1.90% 0x8295
10 527 Green 1.90% 0x8163 (Very Close to Above Green) //this one is an approximation
5 527 Dark Green 0.95% 0x87D4
1 527 Valorite 0.19% 0x88AB
1 527 Midnight Blue 0.19% 0x8258
* */
if (rand <= 0)
@ -264,7 +264,6 @@ namespace Server.Mobiles
{
m_Mobile = m;
m_Mod = mod;
Priority = TimerPriority.TwoFiftyMS;
}
public void DoExpire()

View file

@ -5599,7 +5599,6 @@ namespace Server.Mobiles
public DeleteTimer(Mobile creature, TimeSpan delay) : base(delay)
{
m = creature;
Priority = TimerPriority.OneMinute;
}
protected override void OnTick()
@ -5618,7 +5617,6 @@ namespace Server.Mobiles
public LoyaltyTimer() : base(InternalDelay, InternalDelay)
{
m_NextHourlyCheck = Core.Now + TimeSpan.FromHours(1.0);
Priority = TimerPriority.FiveSeconds;
}
public static void Initialize()

View file

@ -155,7 +155,6 @@ namespace Server.Mobiles
{
m_Mobile = m;
m_From = from;
Priority = TimerPriority.TwoFiftyMS;
}
protected override void OnTick()

View file

@ -105,7 +105,6 @@ namespace Server.Mobiles
public UnhideTimer(ShadowFiend owner) : base(TimeSpan.FromSeconds(30.0))
{
m_Owner = owner;
Priority = TimerPriority.OneSecond;
}
protected override void OnTick()

View file

@ -53,10 +53,10 @@ namespace Server.Mobiles
public override void OnDeath( Container c )
{
base.OnDeath( c );
if (Utility.RandomDouble() < 0.15)
c.DropItem( new DisintegratingThesisNotes() );
if (Utility.RandomDouble() < 0.1)
c.DropItem( new ParrotItem() );
}
@ -120,7 +120,6 @@ namespace Server.Mobiles
{
m_Mobile = m;
m_Mod = mod;
Priority = TimerPriority.TwoFiftyMS;
}
public void DoExpire()

View file

@ -79,14 +79,13 @@ namespace Server.Mobiles
private Mobile m_From;
private Mobile m_Mobile;
private int m_Count;
public InternalTimer( Mobile from, Mobile m ) : base( TimeSpan.FromSeconds( 1.0 ), TimeSpan.FromSeconds( 1.0 ) )
{
m_From = from;
m_Mobile = m;
Priority = TimerPriority.TwoFiftyMS;
}
}*/
}
}

View file

@ -47,7 +47,7 @@ namespace Server.Mobiles
public override void OnDeath( Container c )
{
base.OnDeath( c );
if (Utility.RandomDouble() < 0.025)
{
switch ( Utility.Random( 18 ) )
@ -72,7 +72,7 @@ namespace Server.Mobiles
case 17: c.DropItem( new GreymistGloves() ); break;
}
}
if (Utility.RandomDouble() < 0.1)
c.DropItem( new ParrotItem() );
}
@ -153,7 +153,6 @@ namespace Server.Mobiles
{
m_Mobile = m;
m_Mod = mod;
Priority = TimerPriority.TwoFiftyMS;
}
public void DoExpire()

View file

@ -102,7 +102,6 @@ namespace Server.Mobiles
{
m_Mobile = m;
m_From = from;
Priority = TimerPriority.TwoFiftyMS;
}
protected override void OnTick()

View file

@ -242,7 +242,6 @@ namespace Server.Mobiles
{
m_Mobile = m;
m_From = from;
Priority = TimerPriority.TwoFiftyMS;
}
public void DoExpire()

View file

@ -175,7 +175,6 @@ namespace Server.Mobiles
{
m_Mobile = m;
m_Mod = mod;
Priority = TimerPriority.TwoFiftyMS;
}
protected override void OnTick()

View file

@ -189,7 +189,6 @@ namespace Server.Mobiles
{
m_From = from;
m_Mobile = m;
Priority = TimerPriority.TwoFiftyMS;
}
protected override void OnTick()

View file

@ -157,7 +157,6 @@ namespace Server.Mobiles
m_Mobile = m;
m_Mod = mod;
m_Table = table;
Priority = TimerPriority.TwoFiftyMS;
}
public void DoExpire()

View file

@ -131,7 +131,6 @@ namespace Server.Mobiles
{
m_Mobile = m;
m_From = from;
Priority = TimerPriority.TwoFiftyMS;
}
public void DoExpire()

View file

@ -107,7 +107,6 @@ namespace Server.Mobiles
public ExpireTimer(Mobile m, TimeSpan delay) : base(delay)
{
m_Mobile = m;
Priority = TimerPriority.TwoFiftyMS;
}
public void DoExpire()

View file

@ -248,7 +248,6 @@ namespace Server.Mobiles
{
m_Mobile = m;
m_Mods = mods;
Priority = TimerPriority.TwoFiftyMS;
}
public void DoExpire()

View file

@ -146,7 +146,6 @@ namespace Server.Mobiles
{
m_Mobile = m;
m_From = from;
Priority = TimerPriority.TwoFiftyMS;
}
public void DoExpire()

View file

@ -236,8 +236,6 @@ namespace Server.Mobiles
public ExpirePolymorphTimer(Mobile owner) : base(TimeSpan.FromMinutes(3.0))
{
m_Owner = owner;
Priority = TimerPriority.OneSecond;
}
protected override void OnTick()

View file

@ -151,7 +151,6 @@ namespace Server.Mobiles
public AutokillTimer(Dummy owner) : base(TimeSpan.FromMinutes(5.0))
{
m_Owner = owner;
Priority = TimerPriority.FiveSeconds;
}
protected override void OnTick()

View file

@ -546,7 +546,6 @@ namespace Server.Mobiles
public TeleportTimer(Mobile owner) : base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(5.0))
{
Priority = TimerPriority.TwoFiftyMS;
m_Owner = owner;
}
@ -643,7 +642,6 @@ namespace Server.Mobiles
public GoodiesTimer(Map map, int x, int y) : base(TimeSpan.FromSeconds(Utility.RandomDouble() * 10.0))
{
Priority = TimerPriority.TwoFiftyMS;
m_Map = map;
m_X = x;

View file

@ -132,7 +132,6 @@ namespace Server.Mobiles
public DrainTimer(HarrowerTentacles owner) : base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(5.0))
{
m_Owner = owner;
Priority = TimerPriority.TwoFiftyMS;
}
protected override void OnTick()

View file

@ -236,7 +236,6 @@ namespace Server.Mobiles
public ParagonStamRegen(Mobile m)
: base(FastRegenRate, FastRegenRate)
{
Priority = TimerPriority.FiftyMS;
m_Owner = m as BaseCreature;
}

View file

@ -708,8 +708,6 @@ namespace Server.Mobiles
: base(delay)
{
m_Mobile = m;
Priority = TimerPriority.OneSecond;
}
protected override void OnTick()

View file

@ -1352,8 +1352,6 @@ namespace Server.Mobiles
public PayTimer(PlayerVendor vendor, TimeSpan delay) : base(delay, GetInterval())
{
m_Vendor = vendor;
Priority = TimerPriority.OneMinute;
}
public static TimeSpan GetInterval()
@ -1706,8 +1704,6 @@ namespace Server.Mobiles
public ExpireTimer(PlayerVendorPlaceholder placeholder) : base(TimeSpan.FromMinutes(2.0))
{
m_Placeholder = placeholder;
Priority = TimerPriority.FiveSeconds;
}
protected override void OnTick()

View file

@ -365,8 +365,6 @@ namespace Server.Mobiles
public RentalExpireTimer(RentedVendor vendor, TimeSpan delay) : base(delay, vendor.RentalDuration.Duration)
{
m_Vendor = vendor;
Priority = TimerPriority.OneMinute;
}
protected override void OnTick()

View file

@ -108,8 +108,6 @@ namespace Server.Mobiles
public ExpireTimer(VendorInventory inventory, TimeSpan delay) : base(delay)
{
m_Inventory = inventory;
Priority = TimerPriority.OneMinute;
}
protected override void OnTick()