Class ValueTaskSynchronization
Provides a set of methods for synchronization and combination of multiple ValueTasks.
Inherited Members
Namespace: DotNext.Threading.Tasks
Assembly: DotNext.Threading.dll
Syntax
public static class ValueTaskSynchronization
Remarks
Methods in this class exist for architectural symmetry with WhenAll
and WhenAny
methods
from Task class when you have to work with tasks implemented as value types.
Don't use these methods just to avoid allocation of memory inside of managed heap.
Methods
| Improve this Doc View SourceWhenAll(ValueTask, ValueTask)
Creates a task that will complete when all of the passed tasks have completed.
Declaration
public static ValueTask WhenAll(ValueTask task1, ValueTask task2)
Parameters
Type | Name | Description |
---|---|---|
ValueTask | task1 | The first task to await. |
ValueTask | task2 | The second task to await. |
Returns
Type | Description |
---|---|
ValueTask | A task that represents the completion of all of the supplied tasks. |
Remarks
This method avoid memory allocation in the managed heap if all tasks are completed (or will be soon) at the time of calling this method.
WhenAll(ValueTask, ValueTask, ValueTask)
Creates a task that will complete when all of the passed tasks have completed.
Declaration
public static ValueTask WhenAll(ValueTask task1, ValueTask task2, ValueTask task3)
Parameters
Type | Name | Description |
---|---|---|
ValueTask | task1 | The first task to await. |
ValueTask | task2 | The second task to await. |
ValueTask | task3 | The third task to await. |
Returns
Type | Description |
---|---|
ValueTask | A task that represents the completion of all of the supplied tasks. |
Remarks
This method avoid memory allocation in the managed heap if all tasks are completed (or will be soon) at the time of calling this method.
WhenAll(ValueTask, ValueTask, ValueTask, ValueTask)
Creates a task that will complete when all of the passed tasks have completed.
Declaration
public static ValueTask WhenAll(ValueTask task1, ValueTask task2, ValueTask task3, ValueTask task4)
Parameters
Type | Name | Description |
---|---|---|
ValueTask | task1 | The first task to await. |
ValueTask | task2 | The second task to await. |
ValueTask | task3 | The third task to await. |
ValueTask | task4 | The fourth task to await. |
Returns
Type | Description |
---|---|
ValueTask | A task that represents the completion of all of the supplied tasks. |
Remarks
This method avoid memory allocation in the managed heap if all tasks are completed (or will be soon) at the time of calling this method.
WhenAll(ValueTask, ValueTask, ValueTask, ValueTask, ValueTask)
Creates a task that will complete when all of the passed tasks have completed.
Declaration
public static ValueTask WhenAll(ValueTask task1, ValueTask task2, ValueTask task3, ValueTask task4, ValueTask task5)
Parameters
Type | Name | Description |
---|---|---|
ValueTask | task1 | The first task to await. |
ValueTask | task2 | The second task to await. |
ValueTask | task3 | The third task to await. |
ValueTask | task4 | The fourth task to await. |
ValueTask | task5 | The fifth task to await. |
Returns
Type | Description |
---|---|
ValueTask | A task that represents the completion of all of the supplied tasks. |
Remarks
This method avoid memory allocation in the managed heap if all tasks are completed (or will be soon) at the time of calling this method.
WhenAll<T1, T2>(ValueTask<T1>, ValueTask<T2>)
Creates a task that will complete when all of the passed tasks have completed.
Declaration
public static ValueTask<(T1, T2)> WhenAll<T1, T2>(ValueTask<T1> task1, ValueTask<T2> task2)
Parameters
Type | Name | Description |
---|---|---|
ValueTask<T1> | task1 | The first task to await. |
ValueTask<T2> | task2 | The second task to await. |
Returns
Type | Description |
---|---|
ValueTask<ValueTuple<T1, T2>> | A task containing results of both tasks. |
Type Parameters
Name | Description |
---|---|
T1 | The type of the first task. |
T2 | The type of the second task. |
Remarks
This method avoid memory allocation in the managed heap if all tasks are completed (or will be soon) at the time of calling this method.
WhenAll<T1, T2, T3>(ValueTask<T1>, ValueTask<T2>, ValueTask<T3>)
Creates a task that will complete when all of the passed tasks have completed.
Declaration
public static ValueTask<(T1, T2, T3)> WhenAll<T1, T2, T3>(ValueTask<T1> task1, ValueTask<T2> task2, ValueTask<T3> task3)
Parameters
Type | Name | Description |
---|---|---|
ValueTask<T1> | task1 | The first task to await. |
ValueTask<T2> | task2 | The second task to await. |
ValueTask<T3> | task3 | The third task to await. |
Returns
Type | Description |
---|---|
ValueTask<ValueTuple<T1, T2, T3>> | A task containing results of all tasks. |
Type Parameters
Name | Description |
---|---|
T1 | The type of the first task. |
T2 | The type of the second task. |
T3 | The type of the third task. |
Remarks
This method avoid memory allocation in the managed heap if all tasks are completed (or will be soon) at the time of calling this method.
WhenAll<T1, T2, T3, T4>(ValueTask<T1>, ValueTask<T2>, ValueTask<T3>, ValueTask<T4>)
Creates a task that will complete when all of the passed tasks have completed.
Declaration
public static ValueTask<(T1, T2, T3, T4)> WhenAll<T1, T2, T3, T4>(ValueTask<T1> task1, ValueTask<T2> task2, ValueTask<T3> task3, ValueTask<T4> task4)
Parameters
Type | Name | Description |
---|---|---|
ValueTask<T1> | task1 | The first task to await. |
ValueTask<T2> | task2 | The second task to await. |
ValueTask<T3> | task3 | The third task to await. |
ValueTask<T4> | task4 | The fourth task to await. |
Returns
Type | Description |
---|---|
ValueTask<ValueTuple<T1, T2, T3, T4>> | A task containing results of all tasks. |
Type Parameters
Name | Description |
---|---|
T1 | The type of the first task. |
T2 | The type of the second task. |
T3 | The type of the third task. |
T4 | The type of the fourth task. |
Remarks
This method avoid memory allocation in the managed heap if all tasks are completed (or will be soon) at the time of calling this method.
WhenAll<T1, T2, T3, T4, T5>(ValueTask<T1>, ValueTask<T2>, ValueTask<T3>, ValueTask<T4>, ValueTask<T5>)
Creates a task that will complete when all of the passed tasks have completed.
Declaration
public static ValueTask<(T1, T2, T3, T4, T5)> WhenAll<T1, T2, T3, T4, T5>(ValueTask<T1> task1, ValueTask<T2> task2, ValueTask<T3> task3, ValueTask<T4> task4, ValueTask<T5> task5)
Parameters
Type | Name | Description |
---|---|---|
ValueTask<T1> | task1 | The first task to await. |
ValueTask<T2> | task2 | The second task to await. |
ValueTask<T3> | task3 | The third task to await. |
ValueTask<T4> | task4 | The fourth task to await. |
ValueTask<T5> | task5 | The fifth task to await. |
Returns
Type | Description |
---|---|
ValueTask<ValueTuple<T1, T2, T3, T4, T5>> | A task containing results of all tasks. |
Type Parameters
Name | Description |
---|---|
T1 | The type of the first task. |
T2 | The type of the second task. |
T3 | The type of the third task. |
T4 | The type of the fourth task. |
T5 | The type of the fifth task. |
Remarks
This method avoid memory allocation in the managed heap if all tasks are completed (or will be soon) at the time of calling this method.
WhenAny(ValueTask, ValueTask)
Creates a task that will complete when any of the supplied tasks have completed.
Declaration
public static ValueTask<ValueTask> WhenAny(ValueTask task1, ValueTask task2)
Parameters
Type | Name | Description |
---|---|---|
ValueTask | task1 | The first task to wait on for completion. |
ValueTask | task2 | The second task to wait on for completion. |
Returns
Type | Description |
---|---|
ValueTask<ValueTask> | A task that represents the completion of one of the supplied tasks. The return task's Result is the task that completed. |
Remarks
This method avoid memory allocation in the managed heap if all tasks are completed (or will be soon) at the time of calling this method.
WhenAny(ValueTask, ValueTask, ValueTask)
Creates a task that will complete when any of the supplied tasks have completed.
Declaration
public static ValueTask<ValueTask> WhenAny(ValueTask task1, ValueTask task2, ValueTask task3)
Parameters
Type | Name | Description |
---|---|---|
ValueTask | task1 | The first task to wait on for completion. |
ValueTask | task2 | The second task to wait on for completion. |
ValueTask | task3 | The third task to wait on for completion. |
Returns
Type | Description |
---|---|
ValueTask<ValueTask> | A task that represents the completion of one of the supplied tasks. The return task's Result is the task that completed. |
Remarks
This method avoid memory allocation in the managed heap if all tasks are completed (or will be soon) at the time of calling this method.
WhenAny(ValueTask, ValueTask, ValueTask, ValueTask)
Creates a task that will complete when any of the supplied tasks have completed.
Declaration
public static ValueTask<ValueTask> WhenAny(ValueTask task1, ValueTask task2, ValueTask task3, ValueTask task4)
Parameters
Type | Name | Description |
---|---|---|
ValueTask | task1 | The first task to wait on for completion. |
ValueTask | task2 | The second task to wait on for completion. |
ValueTask | task3 | The third task to wait on for completion. |
ValueTask | task4 | The fourth task to wait on for completion. |
Returns
Type | Description |
---|---|
ValueTask<ValueTask> | A task that represents the completion of one of the supplied tasks. The return task's Result is the task that completed. |
Remarks
This method avoid memory allocation in the managed heap if all tasks are completed (or will be soon) at the time of calling this method.
WhenAny(ValueTask, ValueTask, ValueTask, ValueTask, ValueTask)
Creates a task that will complete when any of the supplied tasks have completed.
Declaration
public static ValueTask<ValueTask> WhenAny(ValueTask task1, ValueTask task2, ValueTask task3, ValueTask task4, ValueTask task5)
Parameters
Type | Name | Description |
---|---|---|
ValueTask | task1 | The first task to wait on for completion. |
ValueTask | task2 | The second task to wait on for completion. |
ValueTask | task3 | The third task to wait on for completion. |
ValueTask | task4 | The fourth task to wait on for completion. |
ValueTask | task5 | The fifth task to wait on for completion. |
Returns
Type | Description |
---|---|
ValueTask<ValueTask> | A task that represents the completion of one of the supplied tasks. The return task's Result is the task that completed. |
Remarks
This method avoid memory allocation in the managed heap if all tasks are completed (or will be soon) at the time of calling this method.
WhenAny<TResult>(ValueTask<TResult>, ValueTask<TResult>)
Creates a task that will complete when any of the supplied tasks have completed.
Declaration
public static ValueTask<ValueTask<TResult>> WhenAny<TResult>(ValueTask<TResult> task1, ValueTask<TResult> task2)
Parameters
Type | Name | Description |
---|---|---|
ValueTask<TResult> | task1 | The first task to wait on for completion. |
ValueTask<TResult> | task2 | The second task to wait on for completion. |
Returns
Type | Description |
---|---|
ValueTask<ValueTask<TResult>> | A task that represents the completion of one of the supplied tasks. The return task's Result is the task that completed. |
Type Parameters
Name | Description |
---|---|
TResult | The type of the result produced by the tasks. |
Remarks
This method avoid memory allocation in the managed heap if all tasks are completed (or will be soon) at the time of calling this method.
WhenAny<TResult>(ValueTask<TResult>, ValueTask<TResult>, ValueTask<TResult>)
Creates a task that will complete when any of the supplied tasks have completed.
Declaration
public static ValueTask<ValueTask<TResult>> WhenAny<TResult>(ValueTask<TResult> task1, ValueTask<TResult> task2, ValueTask<TResult> task3)
Parameters
Type | Name | Description |
---|---|---|
ValueTask<TResult> | task1 | The first task to wait on for completion. |
ValueTask<TResult> | task2 | The second task to wait on for completion. |
ValueTask<TResult> | task3 | The third task to wait on for completion. |
Returns
Type | Description |
---|---|
ValueTask<ValueTask<TResult>> | A task that represents the completion of one of the supplied tasks. The return task's Result is the task that completed. |
Type Parameters
Name | Description |
---|---|
TResult | The type of the result produced by the tasks. |
Remarks
This method avoid memory allocation in the managed heap if all tasks are completed (or will be soon) at the time of calling this method.
WhenAny<TResult>(ValueTask<TResult>, ValueTask<TResult>, ValueTask<TResult>, ValueTask<TResult>)
Creates a task that will complete when any of the supplied tasks have completed.
Declaration
public static ValueTask<ValueTask<TResult>> WhenAny<TResult>(ValueTask<TResult> task1, ValueTask<TResult> task2, ValueTask<TResult> task3, ValueTask<TResult> task4)
Parameters
Type | Name | Description |
---|---|---|
ValueTask<TResult> | task1 | The first task to wait on for completion. |
ValueTask<TResult> | task2 | The second task to wait on for completion. |
ValueTask<TResult> | task3 | The third task to wait on for completion. |
ValueTask<TResult> | task4 | The fourth task to wait on for completion. |
Returns
Type | Description |
---|---|
ValueTask<ValueTask<TResult>> | A task that represents the completion of one of the supplied tasks. The return task's Result is the task that completed. |
Type Parameters
Name | Description |
---|---|
TResult | The type of the result produced by the tasks. |
Remarks
This method avoid memory allocation in the managed heap if all tasks are completed (or will be soon) at the time of calling this method.
WhenAny<TResult>(ValueTask<TResult>, ValueTask<TResult>, ValueTask<TResult>, ValueTask<TResult>, ValueTask<TResult>)
Creates a task that will complete when any of the supplied tasks have completed.
Declaration
public static ValueTask<ValueTask<TResult>> WhenAny<TResult>(ValueTask<TResult> task1, ValueTask<TResult> task2, ValueTask<TResult> task3, ValueTask<TResult> task4, ValueTask<TResult> task5)
Parameters
Type | Name | Description |
---|---|---|
ValueTask<TResult> | task1 | The first task to wait on for completion. |
ValueTask<TResult> | task2 | The second task to wait on for completion. |
ValueTask<TResult> | task3 | The third task to wait on for completion. |
ValueTask<TResult> | task4 | The fourth task to wait on for completion. |
ValueTask<TResult> | task5 | The fifth task to wait on for completion. |
Returns
Type | Description |
---|---|
ValueTask<ValueTask<TResult>> | A task that represents the completion of one of the supplied tasks. The return task's Result is the task that completed. |
Type Parameters
Name | Description |
---|---|
TResult | The type of the result produced by the tasks. |
Remarks
This method avoid memory allocation in the managed heap if all tasks are completed (or will be soon) at the time of calling this method.