Skip to content

Commit 06d336a

Browse files
author
Oren (electricessence)
committed
Fixed issue with async inferrence.
1 parent 7526aee commit 06d336a

3 files changed

Lines changed: 22 additions & 7 deletions

File tree

Open.ChannelExtensions/Extensions.Read.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public static ValueTask<long> ReadAllAsync<TWrite, TRead>(this Channel<TWrite, T
244244
/// <param name="cancellationToken">An optional cancellation token.</param>
245245
/// <returns>A task containing the count of items read that completes when no more reading is to be done.
246246
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
247-
public static ValueTask<long> ReadAllAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel,
247+
public static ValueTask<long> TaskReadAllAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel,
248248
Func<TRead, long, Task> receiver,
249249
CancellationToken cancellationToken = default)
250250
=> channel.Reader.ReadAllAsync((e, i) => new ValueTask(receiver(e, i)), cancellationToken);
@@ -272,7 +272,7 @@ public static ValueTask<long> ReadAllAsync<T>(this ChannelReader<T> reader,
272272
/// <param name="cancellationToken">An optional cancellation token.</param>
273273
/// <returns>A task containing the count of items read that completes when no more reading is to be done.
274274
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
275-
public static ValueTask<long> ReadAllAsync<T>(this ChannelReader<T> reader,
275+
public static ValueTask<long> TaskReadAllAsync<T>(this ChannelReader<T> reader,
276276
Func<T, Task> receiver,
277277
CancellationToken cancellationToken = default)
278278
=> reader.ReadAllAsync((e, i) => new ValueTask(receiver(e)), cancellationToken);
@@ -286,7 +286,7 @@ public static ValueTask<long> ReadAllAsync<T>(this ChannelReader<T> reader,
286286
/// <param name="cancellationToken">An optional cancellation token.</param>
287287
/// <returns>A task containing the count of items read that completes when no more reading is to be done.
288288
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
289-
public static ValueTask<long> ReadAllAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel,
289+
public static ValueTask<long> TaskReadAllAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel,
290290
Func<TRead, Task> receiver,
291291
CancellationToken cancellationToken = default)
292292
=> channel.Reader.ReadAllAsync((e, i) => new ValueTask(receiver(e)), cancellationToken);

Open.ChannelExtensions/Extensions.ReadConcurrently.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,21 @@ public static Task<long> ReadAllConcurrentlyAsync<T>(this ChannelReader<T> reade
5454
ValueTask ParallelReceiver(T item, long i) => receiver(item);
5555
}
5656

57+
/// <summary>
58+
/// Reads items from the channel and passes them to the receiver.
59+
/// </summary>
60+
/// <typeparam name="T">The item type.</typeparam>
61+
/// <param name="reader">The channel reader to read from.</param>
62+
/// <param name="maxConcurrency">The maximum number of concurrent operations.</param>
63+
/// <param name="receiver">The async receiver function.</param>
64+
/// <param name="cancellationToken">An optional cancellation token.</param>
65+
/// <returns>A task that completes when no more reading is to be done.</returns>
66+
public static Task<long> TaskReadAllConcurrentlyAsync<T>(this ChannelReader<T> reader,
67+
int maxConcurrency,
68+
Func<T, Task> receiver,
69+
CancellationToken cancellationToken = default)
70+
=> reader.ReadAllConcurrentlyAsync(maxConcurrency, item => new ValueTask(receiver(item)), cancellationToken);
71+
5772
/// <summary>
5873
/// Reads items from the channel and passes them to the receiver.
5974
/// </summary>
@@ -78,7 +93,7 @@ public static Task<long> ReadAllConcurrentlyAsync<TWrite, TRead>(this Channel<TW
7893
/// <param name="receiver">The async receiver function.</param>
7994
/// <param name="cancellationToken">An optional cancellation token.</param>
8095
/// <returns>A task that completes when no more reading is to be done.</returns>
81-
public static Task<long> ReadAllConcurrentlyAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel,
96+
public static Task<long> TaskReadAllConcurrentlyAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel,
8297
int maxConcurrency,
8398
Func<TRead, Task> receiver,
8499
CancellationToken cancellationToken = default)

Open.ChannelExtensions/Open.ChannelExtensions.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ Part of the "Open" set of libraries.</Description>
1616
<RepositoryType>git</RepositoryType>
1717
<PackageTags>channels dotnet threading tasks extensions</PackageTags>
1818
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
19-
<Version>2.3.2</Version>
19+
<Version>2.3.3</Version>
2020
<PackageLicenseExpression>MIT</PackageLicenseExpression>
21-
<AssemblyVersion>2.3.2.0</AssemblyVersion>
22-
<FileVersion>2.3.2.0</FileVersion>
21+
<AssemblyVersion>2.3.3.0</AssemblyVersion>
22+
<FileVersion>2.3.3.0</FileVersion>
2323
<PackageReleaseNotes></PackageReleaseNotes>
2424
</PropertyGroup>
2525

0 commit comments

Comments
 (0)