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

Hide task scheduler #7074

Open
wants to merge 3 commits 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/core/Akka/Dispatch/Dispatchers.cs
Expand Up @@ -185,10 +185,9 @@ public void ReadChannel()
/// </summary>
internal sealed class TaskSchedulerExecutor : ExecutorService
{
/// <summary>
/// The scheduler
/// </summary>
private TaskScheduler _scheduler;
readonly TaskFactory _factory;

readonly CancellationTokenSource _cts = new CancellationTokenSource();

/// <summary>
/// TBD
Expand All @@ -197,7 +196,7 @@ internal sealed class TaskSchedulerExecutor : ExecutorService
/// <param name="scheduler">TBD</param>
public TaskSchedulerExecutor(string id, TaskScheduler scheduler) : base(id)
{
_scheduler = scheduler;
_factory = new TaskFactory(_cts.Token, TaskCreationOptions.HideScheduler, TaskContinuationOptions.None, scheduler);
}

// cache the delegate used for execution to prevent allocations
Expand All @@ -209,17 +208,16 @@ public TaskSchedulerExecutor(string id, TaskScheduler scheduler) : base(id)
/// <param name="run">TBD</param>
public override void Execute(IRunnable run)
{
var t = new Task(Executor, run);
t.Start(_scheduler);
_factory.StartNew(Executor, run);
}

/// <summary>
/// TBD
/// </summary>
public override void Shutdown()
{
// clear the scheduler
_scheduler = null;
// cancel queued tasks
_cts.Cancel();
}
}

Expand Down