Skip to content

Commit c90eba7

Browse files
committed
Align the names of task list waiters.
1 parent e76961f commit c90eba7

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

src/AsyncFiberWorks/Procedures/AsyncRegisterOfT.cs renamed to src/AsyncFiberWorks/Procedures/SequentialHandlerWaiter.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
namespace AsyncFiberWorks.Procedures
66
{
77
/// <summary>
8-
/// Keep only one value. It provides a task from setting the value
9-
/// to the completion of processing, and a task until it is set.
8+
/// Use "await" to simply wait for the start of a task on a sequential handler list.
109
/// </summary>
1110
/// <typeparam name="T"></typeparam>
12-
public class AsyncRegister<T> : IDisposable
11+
public class SequentialHandlerWaiter<T> : IDisposable
1312
{
1413
private readonly object _lockObj = new object();
1514
private readonly IDisposable _subscription;
@@ -22,23 +21,23 @@ public class AsyncRegister<T> : IDisposable
2221
private CancellationToken _cancellationToken;
2322

2423
/// <summary>
25-
/// Subscribe a handler list.
24+
/// Register a handler to the sequential handler list.
2625
/// </summary>
2726
/// <param name="handlerList"></param>
2827
/// <param name="cancellationToken"></param>
29-
public AsyncRegister(ISequentialHandlerListRegistry<T> handlerList, CancellationToken cancellationToken = default)
28+
public SequentialHandlerWaiter(ISequentialHandlerListRegistry<T> handlerList, CancellationToken cancellationToken = default)
3029
{
3130
_cancellationToken = cancellationToken;
32-
_subscription = handlerList.Add((arg) => SetValueAndWaitClearing(arg));
31+
_subscription = handlerList.Add((arg) => ExecuteAsync(arg));
3332
}
3433

3534
/// <summary>
36-
/// Set the value and wait for it to be cleared.
35+
/// Execute a handler.
3736
/// </summary>
3837
/// <param name="newValue"></param>
3938
/// <returns></returns>
4039
/// <exception cref="InvalidOperationException"></exception>
41-
async Task<bool> SetValueAndWaitClearing(T newValue)
40+
async Task<bool> ExecuteAsync(T newValue)
4241
{
4342
lock (_lockObj)
4443
{
@@ -81,12 +80,12 @@ async Task<bool> SetValueAndWaitClearing(T newValue)
8180
}
8281

8382
/// <summary>
84-
/// Wait for the value to be set.
83+
/// Wait for handler execution.
8584
/// </summary>
8685
/// <returns></returns>
8786
/// <exception cref="ObjectDisposedException"></exception>
8887
/// <exception cref="OperationCanceledException"></exception>
89-
public async Task<ProcessedFlagEventArgs<T>> WaitSetting()
88+
public async Task<ProcessedFlagEventArgs<T>> ExecutionStarted()
9089
{
9190
lock (_lockObj)
9291
{
@@ -117,7 +116,7 @@ public async Task<ProcessedFlagEventArgs<T>> WaitSetting()
117116
}
118117

119118
/// <summary>
120-
/// Unsubscribe.
119+
/// Unregister a handle from the sequential handler list.
121120
/// </summary>
122121
public void Dispose()
123122
{

src/AsyncFiberWorksTests/FiberTaskWaiterTests.cs renamed to src/AsyncFiberWorksTests/SequentialTaskWaiterTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace AsyncFiberWorksTests
99
{
1010
[TestFixture]
11-
public class FiberTaskWaiterTests
11+
public class SequentialTaskWaiterTests
1212
{
1313
[Test]
1414
public async Task TestWait()
@@ -101,12 +101,12 @@ public async Task TestWaitingOfT()
101101

102102
Func<int, Task> func = async (maxCount) =>
103103
{
104-
using (var reg = new AsyncRegister<int>(handlerList))
104+
using (var reg = new SequentialHandlerWaiter<int>(handlerList))
105105
{
106106
int counter = 0;
107107
while (counter < maxCount)
108108
{
109-
var e = await reg.WaitSetting();
109+
var e = await reg.ExecutionStarted();
110110
lock (lockObj)
111111
{
112112
resultCounter += e.Arg;
@@ -147,13 +147,13 @@ public async Task TestCancellationOfT()
147147

148148
var func = new Func<Task>(async () =>
149149
{
150-
using (var reg = new AsyncRegister<int>(handlerList, cancellationToken))
150+
using (var reg = new SequentialHandlerWaiter<int>(handlerList, cancellationToken))
151151
{
152152
try
153153
{
154154
while (true)
155155
{
156-
var ret = await reg.WaitSetting();
156+
var ret = await reg.ExecutionStarted();
157157
lock (lockObj)
158158
{
159159
totalCounter += ret.Arg;
@@ -192,11 +192,11 @@ public async Task TestWaitingOfProcessedFlagEventArgs()
192192
var cts = new CancellationTokenSource();
193193
Func<int, Task> func = async (threshold) =>
194194
{
195-
using (var reg = new AsyncRegister<int>(driver, cts.Token))
195+
using (var reg = new SequentialHandlerWaiter<int>(driver, cts.Token))
196196
{
197197
while (true)
198198
{
199-
var e = await reg.WaitSetting();
199+
var e = await reg.ExecutionStarted();
200200
if (e.Arg < threshold)
201201
{
202202
e.Processed = false;

0 commit comments

Comments
 (0)