Skip to content

Commit

Permalink
Add missing docs for Task API (dotnet#107951)
Browse files Browse the repository at this point in the history
* Add missing docs for Task API

* Apply suggestions from code review

Co-authored-by: Stephen Toub <[email protected]>

---------

Co-authored-by: Stephen Toub <[email protected]>
  • Loading branch information
ericstj and stephentoub authored Sep 18, 2024
1 parent 5d8d04e commit 546f921
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6265,6 +6265,7 @@ public static Task<TResult[]> WhenAll<TResult>(IEnumerable<Task<TResult>> tasks)
/// <summary>
/// Creates a task that will complete when all of the supplied tasks have completed.
/// </summary>
/// <typeparam name="TResult">The type of the result returned by the tasks.</typeparam>
/// <param name="tasks">The tasks to wait on for completion.</param>
/// <returns>A task that represents the completion of all of the supplied tasks.</returns>
/// <remarks>
Expand Down Expand Up @@ -6305,6 +6306,7 @@ public static Task<TResult[]> WhenAll<TResult>(params Task<TResult>[] tasks)
/// <summary>
/// Creates a task that will complete when all of the supplied tasks have completed.
/// </summary>
/// <typeparam name="TResult">The type of the result returned by the tasks.</typeparam>
/// <param name="tasks">The tasks to wait on for completion.</param>
/// <returns>A task that represents the completion of all of the supplied tasks.</returns>
/// <remarks>
Expand Down Expand Up @@ -6679,6 +6681,7 @@ public static Task<Task> WhenAny(IEnumerable<Task> tasks) =>
/// <summary>
/// Creates a task that will complete when any of the supplied tasks have completed.
/// </summary>
/// <typeparam name="TTask">The type of the result returned by the tasks.</typeparam>
/// <param name="tasks">The tasks to wait on for completion.</param>
/// <returns>A task that represents the completion of one of the supplied tasks. The return Task's Result is the task that completed.</returns>
/// <remarks>
Expand Down Expand Up @@ -6753,6 +6756,7 @@ private static Task<TTask> WhenAny<TTask>(IEnumerable<TTask> tasks) where TTask
/// <summary>
/// Creates a task that will complete when any of the supplied tasks have completed.
/// </summary>
/// <typeparam name="TResult">The type of the result returned by the tasks.</typeparam>
/// <param name="tasks">The tasks to wait on for completion.</param>
/// <returns>A task that represents the completion of one of the supplied tasks. The return Task's Result is the task that completed.</returns>
/// <remarks>
Expand All @@ -6775,6 +6779,7 @@ public static Task<Task<TResult>> WhenAny<TResult>(params Task<TResult>[] tasks)
/// <summary>
/// Creates a task that will complete when any of the supplied tasks have completed.
/// </summary>
/// <typeparam name="TResult">The type of the result returned by the tasks.</typeparam>
/// <param name="tasks">The tasks to wait on for completion.</param>
/// <returns>A task that represents the completion of one of the supplied tasks. The return Task's Result is the task that completed.</returns>
/// <remarks>
Expand All @@ -6788,6 +6793,7 @@ public static Task<Task<TResult>> WhenAny<TResult>(params ReadOnlySpan<Task<TRes
WhenAnyCore(tasks);

/// <summary>Creates a task that will complete when either of the supplied tasks have completed.</summary>
/// <typeparam name="TResult">The type of the result returned by the tasks.</typeparam>
/// <param name="task1">The first task to wait on for completion.</param>
/// <param name="task2">The second task to wait on for completion.</param>
/// <returns>A task that represents the completion of one of the supplied tasks. The return Task's Result is the task that completed.</returns>
Expand All @@ -6804,6 +6810,7 @@ public static Task<Task<TResult>> WhenAny<TResult>(Task<TResult> task1, Task<TRe
/// <summary>
/// Creates a task that will complete when any of the supplied tasks have completed.
/// </summary>
/// <typeparam name="TResult">The type of the result returned by the tasks.</typeparam>
/// <param name="tasks">The tasks to wait on for completion.</param>
/// <returns>A task that represents the completion of one of the supplied tasks. The return Task's Result is the task that completed.</returns>
/// <remarks>
Expand Down Expand Up @@ -6837,25 +6844,33 @@ public static IAsyncEnumerable<Task> WhenEach(params Task[] tasks)
}

/// <inheritdoc cref="WhenEach(Task[])"/>
/// <param name="tasks">The tasks to iterate through as they complete.</param>
public static IAsyncEnumerable<Task> WhenEach(ReadOnlySpan<Task> tasks) => // TODO https://github.com/dotnet/runtime/issues/77873: Add params
WhenEachState.Iterate<Task>(WhenEachState.Create(tasks));

/// <inheritdoc cref="WhenEach(Task[])"/>
/// <param name="tasks">The tasks to iterate through as they complete.</param>
public static IAsyncEnumerable<Task> WhenEach(IEnumerable<Task> tasks) =>
WhenEachState.Iterate<Task>(WhenEachState.Create(tasks));

/// <inheritdoc cref="WhenEach(Task[])"/>
/// <typeparam name="TResult">The type of the result returned by the tasks.</typeparam>
/// <param name="tasks">The tasks to iterate through as they complete.</param>
public static IAsyncEnumerable<Task<TResult>> WhenEach<TResult>(params Task<TResult>[] tasks)
{
ArgumentNullException.ThrowIfNull(tasks);
return WhenEach((ReadOnlySpan<Task<TResult>>)tasks);
}

/// <inheritdoc cref="WhenEach(Task[])"/>
/// <typeparam name="TResult">The type of the result returned by the tasks.</typeparam>
/// <param name="tasks">The tasks to iterate through as they complete.</param>
public static IAsyncEnumerable<Task<TResult>> WhenEach<TResult>(ReadOnlySpan<Task<TResult>> tasks) => // TODO https://github.com/dotnet/runtime/issues/77873: Add params
WhenEachState.Iterate<Task<TResult>>(WhenEachState.Create(ReadOnlySpan<Task>.CastUp(tasks)));

/// <inheritdoc cref="WhenEach(Task[])"/>
/// <typeparam name="TResult">The type of the result returned by the tasks.</typeparam>
/// <param name="tasks">The tasks to iterate through as they complete.</param>
public static IAsyncEnumerable<Task<TResult>> WhenEach<TResult>(IEnumerable<Task<TResult>> tasks) =>
WhenEachState.Iterate<Task<TResult>>(WhenEachState.Create(tasks));

Expand Down

0 comments on commit 546f921

Please sign in to comment.