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

@ -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)