Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport HashedWheelTimerFix to .NET Standard 2.0 #7177

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/core/Akka/Actor/Scheduler/HashedWheelTimerScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,10 @@ private void ProcessReschedule(long now)

private void Start()
{
if (_workerState == WORKER_STATE_STARTED) { } // do nothing
else if (_workerState == WORKER_STATE_INIT)
// only read the worker state once so it can't be a moving target for else-branch
var workerStateRead = _workerState;
if (workerStateRead == WORKER_STATE_STARTED) { } // do nothing
else if (workerStateRead == WORKER_STATE_INIT)
{
_worker ??= new Thread(Run) { IsBackground = true };
if (Interlocked.CompareExchange(ref _workerState, WORKER_STATE_STARTED, WORKER_STATE_INIT) ==
Expand All @@ -258,7 +260,7 @@ private void Start()
_worker.Start();
}
}
else if (_workerState is WORKER_STATE_SHUTDOWN)
else if (workerStateRead is WORKER_STATE_SHUTDOWN)
{
throw new SchedulerException("cannot enqueue after timer shutdown");
}
Expand Down
Loading