fix: Fixes timer orphaning issue (#1196)
* Fixes an edge case where a check to see if a timer was being executed resulted in it not being properly detached on stop. Fixed this by changing how we determine what timer is currently being executed. * Adds execution count to #DEBUG_TIMERS so shards can get notified (rudimentarily for now) about sequentially executing long chains of timers. Unfortunately, for now, there is no good option when it comes to executing timers. If we execute let's say 500, and defer the rest, that makes all timers effectively 8ms off until it "catches up". Depending on the shard, that may never happen.
This commit is contained in:
parent
919b7e9416
commit
791128f238
3 changed files with 39 additions and 29 deletions
|
|
@ -153,20 +153,22 @@ public partial class Timer
|
|||
|
||||
Running = false;
|
||||
|
||||
// Do not detach if we are in the middle of executing the timer wheel for this ring/slot
|
||||
if (!_timerWheelExecuting || _ringIndexes[_ring] != _slot)
|
||||
// We are the head on the timer ring
|
||||
if (_rings[_ring][_slot] == this)
|
||||
{
|
||||
// We are at the head
|
||||
if (_rings[_ring][_slot] == this)
|
||||
{
|
||||
_rings[_ring][_slot] = _nextTimer;
|
||||
}
|
||||
|
||||
Detach();
|
||||
OnDetach();
|
||||
_rings[_ring][_slot] = _nextTimer;
|
||||
}
|
||||
|
||||
// We are the head on the executing ring
|
||||
if (_executingRings[_ring] == this)
|
||||
{
|
||||
_executingRings[_ring] = _nextTimer;
|
||||
}
|
||||
|
||||
Detach();
|
||||
|
||||
Version++;
|
||||
OnDetach();
|
||||
|
||||
var prof = GetProfile();
|
||||
if (prof != null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue