Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
TaskRun -> ThreadPool
Browse files Browse the repository at this point in the history
  • Loading branch information
benaadams committed Jan 6, 2018
1 parent d32726a commit 64916f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/System.IO.Pipelines/System/Threading/Scheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ namespace System.Threading
{
public abstract class Scheduler
{
private static TaskRunScheduler _taskRunScheduler = new TaskRunScheduler();
private static ThreadPoolScheduler _threadPoolScheduler = new ThreadPoolScheduler();
private static InlineScheduler _inlineScheduler = new InlineScheduler();

public static Scheduler TaskRun => _taskRunScheduler;
public static Scheduler ThreadPool => _threadPoolScheduler;
public static Scheduler Inline => _inlineScheduler;

public abstract void Schedule(Action action);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

namespace System.Threading
{
internal sealed class TaskRunScheduler : Scheduler
internal sealed class ThreadPoolScheduler : Scheduler
{
public override void Schedule(Action action)
{
#if NETCOREAPP2_1
// Queue to low contention local ThreadPool queue; rather than global queue as per Task
ThreadPool.QueueUserWorkItem(_actionAsTask, action, preferLocal: true);
Threading.ThreadPool.QueueUserWorkItem(_actionAsTask, action, preferLocal: true);
#elif NETSTANDARD2_0
ThreadPool.QueueUserWorkItem(_actionAsTask, action);
Threading.ThreadPool.QueueUserWorkItem(_actionAsTask, action);
#else
Task.Factory.StartNew(action);
#endif
Expand All @@ -24,9 +24,9 @@ public override void Schedule(Action<object> action, object state)
{
#if NETCOREAPP2_1
// Queue to low contention local ThreadPool queue; rather than global queue as per Task
ThreadPool.QueueUserWorkItem(_actionObjectAsTask, new ActionObjectAsTask(action, state), preferLocal: true);
Threading.ThreadPool.QueueUserWorkItem(_actionObjectAsTask, new ActionObjectAsTask(action, state), preferLocal: true);
#elif NETSTANDARD2_0
ThreadPool.QueueUserWorkItem(_actionObjectAsTask, new ActionObjectAsTask(action, state));
Threading.ThreadPool.QueueUserWorkItem(_actionObjectAsTask, new ActionObjectAsTask(action, state));
#else
Task.Factory.StartNew(action, state);
#endif
Expand Down

0 comments on commit 64916f6

Please sign in to comment.