Skip to content

Commit b6a860b

Browse files
committed
Renamed IThreadPool to IDispatcher because it's more appropriate
1 parent e3d35eb commit b6a860b

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

DispatchQueue/ConcurrentQueue.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class ConcurrentQueue : IDispatchQueue
1818
/// <summary>
1919
/// Thread pool interface to submit work to
2020
/// </summary>
21-
private readonly IThreadPool mThreadPool;
21+
private readonly IDispatcher mDispatcher;
2222

2323
#endregion
2424

@@ -29,10 +29,10 @@ public class ConcurrentQueue : IDispatchQueue
2929
/// Constructs a concurrent queue which will schedule work onto the passed thread pool
3030
/// </summary>
3131
/// <param name="threadPool">The thread pool that this SerialQueue will post work to. Must not be null</param>
32-
public ConcurrentQueue(IThreadPool threadPool)
32+
public ConcurrentQueue(IDispatcher dispatcher)
3333
{
34-
mThreadPool = threadPool ?? throw new ArgumentNullException("threadPool");
35-
mTimerQueue = new TimerQueue(this, threadPool);
34+
mDispatcher = dispatcher ?? throw new ArgumentNullException("dispatcher");
35+
mTimerQueue = new TimerQueue(this, dispatcher);
3636
}
3737

3838
#endregion
@@ -47,7 +47,7 @@ public ConcurrentQueue(IThreadPool threadPool)
4747
/// <param name="work">Delegate which will perform the work. Must not be null</param>
4848
public void DispatchAsync(object? context, WaitCallback work)
4949
{
50-
mThreadPool.QueueWorkItem(work, context);
50+
mDispatcher.QueueWorkItem(work, context);
5151
}
5252

5353

DispatchQueue/IThreadPool.cs renamed to DispatchQueue/IDispatcher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Dispatch
44
{
5-
public interface IThreadPool
5+
public interface IDispatcher
66
{
77
public void QueueWorkItem(System.Threading.WaitCallback work, object? context);
88
}

DispatchQueue/ManagedThreadPool.cs renamed to DispatchQueue/ManagedThreadPoolDispatcher.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Dispatch
44
{
5-
public class ManagedThreadPool : IThreadPool
5+
public class ManagedThreadPoolDispatcher : IDispatcher
66
{
7-
public ManagedThreadPool()
7+
public ManagedThreadPoolDispatcher()
88
{
99
}
1010

DispatchQueue/SerialQueue.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private struct WorkData
4141
/// <summary>
4242
/// Thread pool interface to submit work to
4343
/// </summary>
44-
private readonly IThreadPool mThreadPool;
44+
private readonly IDispatcher mDispatcher;
4545

4646

4747
/// <summary>
@@ -79,10 +79,10 @@ private struct WorkData
7979
/// Constructs a SerialQueue which will schedule work onto the passed thread pool
8080
/// </summary>
8181
/// <param name="threadPool">The thread pool that this SerialQueue will post work to. Must not be null</param>
82-
public SerialQueue(IThreadPool threadPool)
82+
public SerialQueue(IDispatcher dispatcher)
8383
{
84-
mThreadPool = threadPool ?? throw new ArgumentNullException("threadPool");
85-
mTimerQueue = new TimerQueue(this, threadPool);
84+
mDispatcher = dispatcher ?? throw new ArgumentNullException("dispatcher");
85+
mTimerQueue = new TimerQueue(this, dispatcher);
8686
mOnExecuteWorkItemFunction = OnExecuteWorkItem;
8787
}
8888

@@ -156,7 +156,7 @@ private void AttemptDequeue()
156156
if (mQueue.TryDequeue(out WorkData work))
157157
{
158158
mCurrentWork = work;
159-
mThreadPool.QueueWorkItem(mOnExecuteWorkItemFunction, null);
159+
mDispatcher.QueueWorkItem(mOnExecuteWorkItemFunction, null);
160160
}
161161
}
162162
}

DispatchQueue/TimerQueue.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public int Compare(TimerQueueData x, TimerQueueData y)
4141
private readonly TimerQueueDataComparer mTimerQueueDataComparer = new TimerQueueDataComparer();
4242

4343
private readonly IDispatchQueue mDispatchQueue;
44-
private readonly IThreadPool mThreadPool;
44+
private readonly IDispatcher mDispatcher;
4545

4646
//mTimerQueueData is used across multiple threads and must be locked
4747
// all TimerQueueData's added to this list will be ordered on insertion from oldest TargetTime to earliest
@@ -55,10 +55,10 @@ public int Compare(TimerQueueData x, TimerQueueData y)
5555

5656
#region Constructors
5757

58-
public TimerQueue(IDispatchQueue dispatchQueue, IThreadPool threadPool)
58+
public TimerQueue(IDispatchQueue dispatchQueue, IDispatcher dispatcher)
5959
{
6060
mDispatchQueue = dispatchQueue ?? throw new ArgumentNullException("dispatchQueue");
61-
mThreadPool = threadPool ?? throw new ArgumentNullException("threadPool");
61+
mDispatcher = dispatcher ?? throw new ArgumentNullException("dispatcher");
6262

6363
mTimer = new Timer(OnTimerExecute);
6464

@@ -90,7 +90,7 @@ public void DispatchAfter(DateTime when, object? context, WaitCallback work)
9090
};
9191

9292
// boxed "data" but ... I don't see an alternative
93-
mThreadPool.QueueWorkItem(mScheduleWorkForExecutionCallback, data);
93+
mDispatcher.QueueWorkItem(mScheduleWorkForExecutionCallback, data);
9494
}
9595

9696
#endregion

0 commit comments

Comments
 (0)