fix: Adds more debugging to the timer system. Simplifies the timer pool. (#1195)

This commit is contained in:
Kamron Batman 2022-10-17 23:25:49 -07:00 • committed by GitHub
parent d5416b6dec
commit 919b7e9416
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 99 additions and 38 deletions

View file

@ -144,11 +144,7 @@ public partial class Timer
internal override void OnDetach()
{
if (Running)
{
logger.Error("Timer is returned while still running!\n{StackTrace}", new StackTrace());
return;
}
base.OnDetach();
if (_returnOnDetach)
{
@ -177,10 +173,6 @@ public partial class Timer
var timer = GetFromPool();
if (timer != null)
{
#if DEBUG_TIMERS
logger.Information("Getting from pool: ({Count} / {Capacity})", _poolCount, _poolCapacity);
#endif
timer.Init(delay, interval, count);
timer._continuation = callback;
timer._returnOnDetach = false;
@ -191,8 +183,6 @@ public partial class Timer
return timer;
}
_timerPoolDepletionAmount++;
#if DEBUG_TIMERS
logger.Warning("Timer pool depleted and timer was allocated.\n{StackTrace}", new StackTrace());
#endif