Class AsyncEventHub
Represents a collection of asynchronous events.
Implements
Inherited Members
Namespace: DotNext.Threading
Assembly: DotNext.Threading.dll
Syntax
public class AsyncEventHub : IResettable
Constructors
| Edit this page View SourceAsyncEventHub(int)
Initializes a new collection of asynchronous events.
Declaration
public AsyncEventHub(int count)
Parameters
Type | Name | Description |
---|---|---|
int | count | The number of asynchronous events. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
Properties
| Edit this page View SourceCount
Gets the number of events.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int |
Methods
| Edit this page View SourceCancelSuspendedCallers(CancellationToken)
Cancels all suspended callers.
Declaration
public void CancelSuspendedCallers(CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | token | The token in canceled state. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
CaptureState(Span<bool>)
Captures the state of the events.
Declaration
public void CaptureState(Span<bool> states)
Parameters
Type | Name | Description |
---|---|---|
Span<bool> | states | A buffer of states to fill. |
Remarks
Each element of the buffer will be modified with the state of the event matching to the index of the element.
Pulse(int)
Turns an event into the signaled state.
Declaration
public bool Pulse(int eventIndex)
Parameters
Type | Name | Description |
---|---|---|
int | eventIndex | The index of the event. |
Returns
Type | Description |
---|---|
bool | true if the event turned into signaled state; false if the event is already in signaled state. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
Pulse(ReadOnlySpan<int>)
Turns the specified events into signaled state.
Declaration
public int Pulse(ReadOnlySpan<int> eventIndexes)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<int> | eventIndexes | A span of event indexes. |
Returns
Type | Description |
---|---|
int | The number of triggered events. |
Pulse(ReadOnlySpan<int>, Span<bool>)
Turns the specified events into signaled state.
Declaration
public void Pulse(ReadOnlySpan<int> eventIndexes, Span<bool> flags)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<int> | eventIndexes | A span of event indexes. |
Span<bool> | flags | A set of event states. The value of each element will be overwritten by the method as follows: true if the corresponding event has been moved to the signaled state, or false if the event is already in signaled state. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | The length of |
PulseAll()
Turns all events into the signaled state.
Declaration
public int PulseAll()
Returns
Type | Description |
---|---|
int | The number of triggered events. |
PulseAll(Span<bool>)
Turns all events into the signaled state.
Declaration
public void PulseAll(Span<bool> flags)
Parameters
Type | Name | Description |
---|---|---|
Span<bool> | flags | A set of event states. The value of each element will be overwritten by the method as follows: true if the corresponding event has been moved to the signaled state, or false if the event is already in signaled state. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | The length of |
Reset()
Turns all events to non-signaled state.
Declaration
public void Reset()
ResetAndPulse(int)
Turns the specified event into the signaled state and reset all other events.
Declaration
public bool ResetAndPulse(int eventIndex)
Parameters
Type | Name | Description |
---|---|---|
int | eventIndex | The index of the event. |
Returns
Type | Description |
---|---|
bool | true if the event turned into signaled state; false if the event is already in signaled state. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
ResetAndPulse(ReadOnlySpan<int>)
Turns the specified events into signaled state and reset all other events.
Declaration
public int ResetAndPulse(ReadOnlySpan<int> eventIndexes)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<int> | eventIndexes | A span of event indexes. |
Returns
Type | Description |
---|---|
int | The number of triggered events. |
ResetAndPulse(ReadOnlySpan<int>, Span<bool>)
Turns the specified events into signaled state and reset all other events.
Declaration
public void ResetAndPulse(ReadOnlySpan<int> eventIndexes, Span<bool> flags)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<int> | eventIndexes | A span of event indexes. |
Span<bool> | flags | A set of event states. The value of each element will be overwritten by the method as follows: true if the corresponding event has been moved to the signaled state, or false if the event is already in signaled state. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | The length of |
WaitAllAsync(ReadOnlySpan<int>, CancellationToken)
Waits for all events.
Declaration
public Task WaitAllAsync(ReadOnlySpan<int> eventIndexes, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<int> | eventIndexes | The indexes of the events. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
Task | A task that represents the completion of all of the specified events. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
WaitAllAsync(ReadOnlySpan<int>, TimeSpan, CancellationToken)
Waits for all events.
Declaration
public Task WaitAllAsync(ReadOnlySpan<int> eventIndexes, TimeSpan timeout, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<int> | eventIndexes | The indexes of the events. |
TimeSpan | timeout | The time to wait for the events. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
Task | A task that represents the completion of all of the specified events. |
Exceptions
Type | Condition |
---|---|
TimeoutException | The operation has timed out. |
OperationCanceledException | The operation has been canceled. |
WaitAllAsync(CancellationToken)
Waits for all events.
Declaration
public Task WaitAllAsync(CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
Task | A task that represents the completion of all of the specified events. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
WaitAllAsync(TimeSpan, CancellationToken)
Waits for all events.
Declaration
public Task WaitAllAsync(TimeSpan timeout, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | timeout | The time to wait for the events. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
Task | A task that represents the completion of all of the specified events. |
Exceptions
Type | Condition |
---|---|
TimeoutException | The operation has timed out. |
OperationCanceledException | The operation has been canceled. |
WaitAnyAsync(ReadOnlySpan<int>, CancellationToken)
Waits for any of the specified events.
Declaration
public Task<int> WaitAnyAsync(ReadOnlySpan<int> eventIndexes, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<int> | eventIndexes | A set of event indexes to wait for. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
Task<int> | The index of the first signaled event. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
OperationCanceledException | The operation has been canceled. |
WaitAnyAsync(ReadOnlySpan<int>, TimeSpan, CancellationToken)
Waits for any of the specified events.
Declaration
public Task<int> WaitAnyAsync(ReadOnlySpan<int> eventIndexes, TimeSpan timeout, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<int> | eventIndexes | A set of event indexes to wait for. |
TimeSpan | timeout | The time to wait for an event. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
Task<int> | The index of the first signaled event. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
TimeoutException | The operation has timed out. |
OperationCanceledException | The operation has been canceled. |
WaitAnyAsync(CancellationToken)
Waits for any of the specified events.
Declaration
public Task<int> WaitAnyAsync(CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
Task<int> | The index of the first signaled event. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
WaitAnyAsync(TimeSpan, CancellationToken)
Waits for any of the specified events.
Declaration
public Task<int> WaitAnyAsync(TimeSpan timeout, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | timeout | The time to wait for an event. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
Task<int> | The index of the first signaled event. |
Exceptions
Type | Condition |
---|---|
TimeoutException | The operation has timed out. |
OperationCanceledException | The operation has been canceled. |
WaitOneAsync(int, CancellationToken)
Waits for the event represented by the specified index.
Declaration
public Task WaitOneAsync(int eventIndex, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
int | eventIndex | The index of the event. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
Task | The task representing the event. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WaitOneAsync(int, TimeSpan, CancellationToken)
Waits for the event represented by the specified index.
Declaration
public Task WaitOneAsync(int eventIndex, TimeSpan timeout, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
int | eventIndex | The index of the event. |
TimeSpan | timeout | The time to wait for an event. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
Task | The task representing the event. |
Exceptions
Type | Condition |
---|---|
TimeoutException | The operation has timed out. |
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|