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:
parent
b99d520019
commit
fb915992dd
138 changed files with 468 additions and 802 deletions
|
|
@ -4,7 +4,28 @@ namespace Server.Misc
|
|||
{
|
||||
public class AutoRestart : Timer
|
||||
{
|
||||
public static bool Enabled; // is the script enabled?
|
||||
private static Timer _autoRestart;
|
||||
private static bool _enabled;
|
||||
|
||||
public static bool Enabled
|
||||
{
|
||||
get => _enabled;
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
_enabled = true;
|
||||
_autoRestart ??= new AutoRestart();
|
||||
_autoRestart.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
_enabled = false;
|
||||
_autoRestart?.Stop();
|
||||
_autoRestart = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly TimeSpan RestartTime = TimeSpan.FromHours(2.0); // time of day at which to restart
|
||||
|
||||
|
|
@ -19,7 +40,6 @@ namespace Server.Misc
|
|||
|
||||
public AutoRestart() : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0))
|
||||
{
|
||||
Priority = TimerPriority.FiveSeconds;
|
||||
|
||||
m_RestartTime = DateTime.UtcNow.Date + RestartTime;
|
||||
|
||||
|
|
@ -31,10 +51,14 @@ namespace Server.Misc
|
|||
|
||||
public static bool Restarting { get; private set; }
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
Enabled = ServerConfiguration.GetOrUpdateSetting("world.enableAutoRestart", false);
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register("Restart", AccessLevel.Administrator, Restart_OnCommand);
|
||||
new AutoRestart().Start();
|
||||
}
|
||||
|
||||
public static void Restart_OnCommand(CommandEventArgs e)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@ namespace Server.Misc
|
|||
public static TimeSpan Warning { get; private set; }
|
||||
public static string BackupPath { get; private set; }
|
||||
|
||||
public AutoSave() : base(Delay - Warning, Delay) => Priority = TimerPriority.OneMinute;
|
||||
public AutoSave() : base(Delay - Warning, Delay)
|
||||
{
|
||||
}
|
||||
|
||||
public static bool SavesEnabled { get; set; } = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,9 @@ namespace Server.Misc
|
|||
{
|
||||
public class FoodDecayTimer : Timer
|
||||
{
|
||||
public FoodDecayTimer() : base(TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5)) =>
|
||||
Priority = TimerPriority.OneMinute;
|
||||
public FoodDecayTimer() : base(TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5))
|
||||
{
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -546,8 +546,9 @@ namespace Server.Guilds
|
|||
|
||||
public class WarTimer : Timer
|
||||
{
|
||||
public WarTimer() : base(TimeSpan.FromMinutes(1.0), TimeSpan.FromMinutes(1.0)) =>
|
||||
Priority = TimerPriority.FiveSeconds;
|
||||
public WarTimer() : base(TimeSpan.FromMinutes(1.0), TimeSpan.FromMinutes(1.0))
|
||||
{
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -92,8 +92,9 @@ namespace Server
|
|||
|
||||
private class LightCycleTimer : Timer
|
||||
{
|
||||
public LightCycleTimer() : base(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(5.0)) =>
|
||||
Priority = TimerPriority.FiveSeconds;
|
||||
public LightCycleTimer() : base(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(5.0))
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
|
|
@ -111,7 +112,6 @@ namespace Server
|
|||
public NightSightTimer(Mobile owner) : base(TimeSpan.FromMinutes(Utility.Random(15, 25)))
|
||||
{
|
||||
m_Owner = owner;
|
||||
Priority = TimerPriority.OneMinute;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ namespace Server.Misc
|
|||
|
||||
private static readonly object _StatusLock = new();
|
||||
|
||||
public StatusPage()
|
||||
: base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(60.0)) =>
|
||||
Priority = TimerPriority.FiveSeconds;
|
||||
public StatusPage() : base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(60.0))
|
||||
{
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue