Skip to content

Commit ee55bd0

Browse files
Reformatting.
1 parent 776ae7b commit ee55bd0

File tree

2 files changed

+87
-31
lines changed

2 files changed

+87
-31
lines changed

Open.ChannelExtensions/Extensions.Write.cs

Lines changed: 66 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ public static partial class Extensions
2424
/// <param name="cancellationToken">An optional cancellation token.</param>
2525
/// <returns>A task containing the count of items written that completes when all the data has been written to the channel writer.
2626
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
27-
public static async ValueTask<long> WriteAllAsync<T>(this ChannelWriter<T> target,
28-
IEnumerable<ValueTask<T>> source, bool complete = false, bool deferredExecution = false, CancellationToken cancellationToken = default)
27+
public static async ValueTask<long> WriteAllAsync<T>(
28+
this ChannelWriter<T> target,
29+
IEnumerable<ValueTask<T>> source,
30+
bool complete = false,
31+
bool deferredExecution = false,
32+
CancellationToken cancellationToken = default)
2933
{
3034
if (target is null) throw new ArgumentNullException(nameof(target));
3135
if (source is null) throw new ArgumentNullException(nameof(source));
@@ -73,8 +77,11 @@ public static async ValueTask<long> WriteAllAsync<T>(this ChannelWriter<T> targe
7377
/// <param name="cancellationToken">The cancellation token.</param>
7478
/// <returns>A task containing the count of items written that completes when all the data has been written to the channel writer.
7579
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
76-
public static ValueTask<long> WriteAllAsync<T>(this ChannelWriter<T> target,
77-
IEnumerable<ValueTask<T>> source, bool complete, CancellationToken cancellationToken)
80+
public static ValueTask<long> WriteAllAsync<T>(
81+
this ChannelWriter<T> target,
82+
IEnumerable<ValueTask<T>> source,
83+
bool complete,
84+
CancellationToken cancellationToken)
7885
=> WriteAllAsync(target, source, complete, false, cancellationToken);
7986

8087
/// <summary>
@@ -88,8 +95,12 @@ public static ValueTask<long> WriteAllAsync<T>(this ChannelWriter<T> target,
8895
/// <param name="cancellationToken">An optional cancellation token.</param>
8996
/// <returns>A task containing the count of items written that completes when all the data has been written to the channel writer.
9097
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
91-
public static ValueTask<long> WriteAllAsync<T>(this ChannelWriter<T> target,
92-
IEnumerable<Task<T>> source, bool complete = false, bool deferredExecution = false, CancellationToken cancellationToken = default)
98+
public static ValueTask<long> WriteAllAsync<T>(
99+
this ChannelWriter<T> target,
100+
IEnumerable<Task<T>> source,
101+
bool complete = false,
102+
bool deferredExecution = false,
103+
CancellationToken cancellationToken = default)
93104
{
94105
if (target is null) throw new ArgumentNullException(nameof(target));
95106
if (source is null) throw new ArgumentNullException(nameof(source));
@@ -113,8 +124,11 @@ public static ValueTask<long> WriteAllAsync<T>(this ChannelWriter<T> target,
113124
/// <param name="cancellationToken">The cancellation token.</param>
114125
/// <returns>A task containing the count of items written that completes when all the data has been written to the channel writer.
115126
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
116-
public static ValueTask<long> WriteAllAsync<T>(this ChannelWriter<T> target,
117-
IEnumerable<Task<T>> source, bool complete, CancellationToken cancellationToken)
127+
public static ValueTask<long> WriteAllAsync<T>(
128+
this ChannelWriter<T> target,
129+
IEnumerable<Task<T>> source,
130+
bool complete,
131+
CancellationToken cancellationToken)
118132
=> WriteAllAsync(target, source, complete, false, cancellationToken);
119133

120134
/// <summary>
@@ -128,8 +142,12 @@ public static ValueTask<long> WriteAllAsync<T>(this ChannelWriter<T> target,
128142
/// <param name="cancellationToken">An optional cancellation token.</param>
129143
/// <returns>A task containing the count of items written that completes when all the data has been written to the channel writer.
130144
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
131-
public static ValueTask<long> WriteAllAsync<T>(this ChannelWriter<T> target,
132-
IEnumerable<Func<T>> source, bool complete = false, bool deferredExecution = false, CancellationToken cancellationToken = default)
145+
public static ValueTask<long> WriteAllAsync<T>(
146+
this ChannelWriter<T> target,
147+
IEnumerable<Func<T>> source,
148+
bool complete = false,
149+
bool deferredExecution = false,
150+
CancellationToken cancellationToken = default)
133151
{
134152
if (target is null) throw new ArgumentNullException(nameof(target));
135153
if (source is null) throw new ArgumentNullException(nameof(source));
@@ -153,8 +171,11 @@ public static ValueTask<long> WriteAllAsync<T>(this ChannelWriter<T> target,
153171
/// <param name="cancellationToken">The cancellation token.</param>
154172
/// <returns>A task containing the count of items written that completes when all the data has been written to the channel writer.
155173
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
156-
public static ValueTask<long> WriteAllAsync<T>(this ChannelWriter<T> target,
157-
IEnumerable<Func<T>> source, bool complete, CancellationToken cancellationToken)
174+
public static ValueTask<long> WriteAllAsync<T>(
175+
this ChannelWriter<T> target,
176+
IEnumerable<Func<T>> source,
177+
bool complete,
178+
CancellationToken cancellationToken)
158179
=> WriteAllAsync(target, source, complete, false, cancellationToken);
159180

160181
/// <summary>
@@ -168,8 +189,12 @@ public static ValueTask<long> WriteAllAsync<T>(this ChannelWriter<T> target,
168189
/// <param name="cancellationToken">An optional cancellation token.</param>
169190
/// <returns>A task containing the count of items written that completes when all the data has been written to the channel writer.
170191
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
171-
public static ValueTask<long> WriteAll<T>(this ChannelWriter<T> target,
172-
IEnumerable<T> source, bool complete = false, bool deferredExecution = false, CancellationToken cancellationToken = default)
192+
public static ValueTask<long> WriteAll<T>(
193+
this ChannelWriter<T> target,
194+
IEnumerable<T> source,
195+
bool complete = false,
196+
bool deferredExecution = false,
197+
CancellationToken cancellationToken = default)
173198
{
174199
if (target is null) throw new ArgumentNullException(nameof(target));
175200
if (source is null) throw new ArgumentNullException(nameof(source));
@@ -193,8 +218,11 @@ public static ValueTask<long> WriteAll<T>(this ChannelWriter<T> target,
193218
/// <param name="cancellationToken">The cancellation token.</param>
194219
/// <returns>A task containing the count of items written that completes when all the data has been written to the channel writer.
195220
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
196-
public static ValueTask<long> WriteAll<T>(this ChannelWriter<T> target,
197-
IEnumerable<T> source, bool complete, CancellationToken cancellationToken)
221+
public static ValueTask<long> WriteAll<T>(
222+
this ChannelWriter<T> target,
223+
IEnumerable<T> source,
224+
bool complete,
225+
CancellationToken cancellationToken)
198226
=> WriteAll(target, source, complete, false, cancellationToken);
199227

200228

@@ -209,8 +237,12 @@ public static ValueTask<long> WriteAll<T>(this ChannelWriter<T> target,
209237
/// <returns>A task containing the count of items written that completes when all the data has been written to the channel writer.
210238
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
211239
[System.Diagnostics.CodeAnalysis.SuppressMessage("Reliability", "CA2012:Use ValueTasks correctly", Justification = "Is used correctly.")]
212-
public static async ValueTask<long> WriteAllLines(this ChannelWriter<string> target,
213-
TextReader source, bool complete = false, bool deferredExecution = false, CancellationToken cancellationToken = default)
240+
public static async ValueTask<long> WriteAllLines(
241+
this ChannelWriter<string> target,
242+
TextReader source,
243+
bool complete = false,
244+
bool deferredExecution = false,
245+
CancellationToken cancellationToken = default)
214246
{
215247
if (target is null) throw new ArgumentNullException(nameof(target));
216248
if (source is null) throw new ArgumentNullException(nameof(source));
@@ -270,8 +302,11 @@ public static async ValueTask<long> WriteAllLines(this ChannelWriter<string> tar
270302
/// <param name="cancellationToken">An optional cancellation token.</param>
271303
/// <returns>A task containing the count of items written that completes when all the data has been written to the channel writer.
272304
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
273-
public static ValueTask<long> WriteAllLines(this ChannelWriter<string> target,
274-
TextReader source, bool complete, CancellationToken cancellationToken)
305+
public static ValueTask<long> WriteAllLines(
306+
this ChannelWriter<string> target,
307+
TextReader source,
308+
bool complete,
309+
CancellationToken cancellationToken)
275310
=> WriteAllLines(target, source, complete, false, cancellationToken);
276311

277312
#if NETSTANDARD2_1
@@ -286,8 +321,12 @@ public static ValueTask<long> WriteAllLines(this ChannelWriter<string> target,
286321
/// <param name="cancellationToken">An optional cancellation token.</param>
287322
/// <returns>A task containing the count of items written that completes when all the data has been written to the channel writer.
288323
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
289-
public static async ValueTask<long> WriteAllAsync<T>(this ChannelWriter<T> target,
290-
IAsyncEnumerable<T> source, bool complete = false, bool deferredExecution = false, CancellationToken cancellationToken = default)
324+
public static async ValueTask<long> WriteAllAsync<T>(
325+
this ChannelWriter<T> target,
326+
IAsyncEnumerable<T> source,
327+
bool complete = false,
328+
bool deferredExecution = false,
329+
CancellationToken cancellationToken = default)
291330
{
292331
if (target is null) throw new ArgumentNullException(nameof(target));
293332
if (source is null) throw new ArgumentNullException(nameof(source));
@@ -336,8 +375,11 @@ await target
336375
/// <param name="cancellationToken">An optional cancellation token.</param>
337376
/// <returns>A task containing the count of items written that completes when all the data has been written to the channel writer.
338377
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
339-
public static ValueTask<long> WriteAllAsync<T>(this ChannelWriter<T> target,
340-
IAsyncEnumerable<T> source, bool complete, CancellationToken cancellationToken)
378+
public static ValueTask<long> WriteAllAsync<T>(
379+
this ChannelWriter<T> target,
380+
IAsyncEnumerable<T> source,
381+
bool complete,
382+
CancellationToken cancellationToken)
341383
=> WriteAllAsync(target, source, complete, false, cancellationToken);
342384
#endif
343385
}

Open.ChannelExtensions/Extensions.WriteConcurrently.cs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@ public static partial class Extensions
2222
/// <returns>A task containing the count of items written that completes when all the data has been written to the channel writer.
2323
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
2424

25-
public static Task<long> WriteAllConcurrentlyAsync<T>(this ChannelWriter<T> target,
26-
int maxConcurrency, IEnumerable<ValueTask<T>> source, bool complete = false, CancellationToken cancellationToken = default)
25+
public static Task<long> WriteAllConcurrentlyAsync<T>(
26+
this ChannelWriter<T> target,
27+
int maxConcurrency,
28+
IEnumerable<ValueTask<T>> source,
29+
bool complete = false,
30+
CancellationToken cancellationToken = default)
2731
{
2832
if (target is null) throw new ArgumentNullException(nameof(target));
2933
if (source is null) throw new ArgumentNullException(nameof(source));
@@ -101,7 +105,9 @@ async Task<long> WriteAllAsyncCore()
101105
}
102106
}
103107

104-
static bool TryMoveNextSynchronized<T>(IEnumerator<T> source, out T value)
108+
static bool TryMoveNextSynchronized<T>(
109+
IEnumerator<T> source,
110+
out T value)
105111
{
106112
lock (source)
107113
{
@@ -127,8 +133,12 @@ static bool TryMoveNextSynchronized<T>(IEnumerator<T> source, out T value)
127133
/// <param name="cancellationToken">An optional cancellation token.</param>
128134
/// <returns>A task containing the count of items written that completes when all the data has been written to the channel writer.
129135
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
130-
public static Task<long> WriteAllConcurrentlyAsync<T>(this ChannelWriter<T> target,
131-
int maxConcurrency, IEnumerable<Task<T>> source, bool complete = false, CancellationToken cancellationToken = default)
136+
public static Task<long> WriteAllConcurrentlyAsync<T>(
137+
this ChannelWriter<T> target,
138+
int maxConcurrency,
139+
IEnumerable<Task<T>> source,
140+
bool complete = false,
141+
CancellationToken cancellationToken = default)
132142
=> WriteAllConcurrentlyAsync(target, maxConcurrency, source.Select(e => new ValueTask<T>(e)), complete, cancellationToken);
133143

134144
/// <summary>
@@ -142,7 +152,11 @@ public static Task<long> WriteAllConcurrentlyAsync<T>(this ChannelWriter<T> targ
142152
/// <param name="cancellationToken">An optional cancellation token.</param>
143153
/// <returns>A task containing the count of items written that completes when all the data has been written to the channel writer.
144154
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
145-
public static Task<long> WriteAllConcurrentlyAsync<T>(this ChannelWriter<T> target,
146-
int maxConcurrency, IEnumerable<Func<T>> source, bool complete = false, CancellationToken cancellationToken = default)
155+
public static Task<long> WriteAllConcurrentlyAsync<T>(
156+
this ChannelWriter<T> target,
157+
int maxConcurrency,
158+
IEnumerable<Func<T>> source,
159+
bool complete = false,
160+
CancellationToken cancellationToken = default)
147161
=> WriteAllConcurrentlyAsync(target, maxConcurrency, source.Select(e => new ValueTask<T>(e())), complete, cancellationToken);
148162
}

0 commit comments

Comments
 (0)