Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkatufus committed Aug 22, 2023
1 parent 954b0f3 commit 8fab2a9
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/core/Akka/Actor/Scheduler/HashedWheelTimerScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,16 +319,27 @@ private void Run()
_stopped.Value?.TrySetResult(_unprocessedRegistrations);
}

private void ProcessReschedule()
{
foreach (var sched in _rescheduleRegistrations)
{
var nextDeadline = HighResMonotonicClock.Ticks - _startTime + sched.Offset;
sched.Deadline = nextDeadline;
PlaceInBucket(sched);
}

_rescheduleRegistrations.Clear();
}

private long WaitForNextTick()
{
long deadline = _tickDuration * (_tick + 1);
var deadline = _tickDuration * (_tick + 1);
unchecked // just to avoid trouble with long-running applications
{
for (;;)
{
long currentTime = HighResMonotonicClock.Ticks - _startTime;
var sleepMs = ((deadline - currentTime + TimeSpan.TicksPerMillisecond - 1) /
TimeSpan.TicksPerMillisecond);
var sleepMs = ((deadline - currentTime + TimeSpan.TicksPerMillisecond - 1) / TimeSpan.TicksPerMillisecond);

if (sleepMs <= 0) // no need to sleep
{
Expand All @@ -341,18 +352,6 @@ private long WaitForNextTick()
}
}
}

private void ProcessReschedule()
{
foreach (var sched in _rescheduleRegistrations)
{
var nextDeadline = HighResMonotonicClock.Ticks - _startTime + sched.Offset;
sched.Deadline = nextDeadline;
PlaceInBucket(sched);
}

_rescheduleRegistrations.Clear();
}
#endif


Expand Down

0 comments on commit 8fab2a9

Please sign in to comment.