Enables multiple tasks to cooperatively work on an algorithm in parallel through multiple phases.
More...
|
| Barrier (int participantCount) |
| Initializes a new instance of the T:System.Threading.Barrier class. More...
|
|
| Barrier (int participantCount, Action< Barrier > postPhaseAction) |
| Initializes a new instance of the T:System.Threading.Barrier class. More...
|
|
long | AddParticipant () |
| Notifies the T:System.Threading.Barrier that there will be an additional participant. More...
|
|
long | AddParticipants (int participantCount) |
| Notifies the T:System.Threading.Barrier that there will be additional participants. More...
|
|
void | RemoveParticipant () |
| Notifies the T:System.Threading.Barrier that there will be one less participant. More...
|
|
void | RemoveParticipants (int participantCount) |
| Notifies the T:System.Threading.Barrier that there will be fewer participants. More...
|
|
void | SignalAndWait () |
| Signals that a participant has reached the barrier and waits for all other participants to reach the barrier as well. More...
|
|
void | SignalAndWait (CancellationToken cancellationToken) |
| Signals that a participant has reached the barrier and waits for all other participants to reach the barrier, while observing a cancellation token. More...
|
|
bool | SignalAndWait (TimeSpan timeout) |
| Signals that a participant has reached the barrier and waits for all other participants to reach the barrier as well, using a T:System.TimeSpan object to measure the time interval. More...
|
|
bool | SignalAndWait (TimeSpan timeout, CancellationToken cancellationToken) |
| Signals that a participant has reached the barrier and waits for all other participants to reach the barrier as well, using a T:System.TimeSpan object to measure the time interval, while observing a cancellation token. More...
|
|
bool | SignalAndWait (int millisecondsTimeout) |
| Signals that a participant has reached the barrier and waits for all other participants to reach the barrier as well, using a 32-bit signed integer to measure the timeout. More...
|
|
bool | SignalAndWait (int millisecondsTimeout, CancellationToken cancellationToken) |
| Signals that a participant has reached the barrier and waits for all other participants to reach the barrier as well, using a 32-bit signed integer to measure the timeout, while observing a cancellation token. More...
|
|
void | Dispose () |
| Releases all resources used by the current instance of the T:System.Threading.Barrier class. More...
|
|
|
virtual void | Dispose (bool disposing) |
| Releases the unmanaged resources used by the T:System.Threading.Barrier, and optionally releases the managed resources. More...
|
|
Enables multiple tasks to cooperatively work on an algorithm in parallel through multiple phases.
Definition at line 13 of file Barrier.cs.
◆ Barrier() [1/2]
System.Threading.Barrier.Barrier |
( |
int |
participantCount | ) |
|
Initializes a new instance of the T:System.Threading.Barrier class.
- Parameters
-
participantCount | The number of participating threads. |
- Exceptions
-
T:System.ArgumentOutOfRangeException | participantCount is less than 0 or greater than 32,767. |
Definition at line 92 of file Barrier.cs.
◆ Barrier() [2/2]
System.Threading.Barrier.Barrier |
( |
int |
participantCount, |
|
|
Action< Barrier > |
postPhaseAction |
|
) |
| |
Initializes a new instance of the T:System.Threading.Barrier class.
- Parameters
-
participantCount | The number of participating threads. |
postPhaseAction | The T:System.Action`1 to be executed after each phase. null (Nothing in Visual Basic) may be passed to indicate no action is taken. |
- Exceptions
-
T:System.ArgumentOutOfRangeException | participantCount is less than 0 or greater than 32,767. |
Definition at line 103 of file Barrier.cs.
◆ AddParticipant()
long System.Threading.Barrier.AddParticipant |
( |
| ) |
|
Notifies the T:System.Threading.Barrier that there will be an additional participant.
- Returns
- The phase number of the barrier in which the new participants will first participate.
- Exceptions
-
T:System.ObjectDisposedException | The current instance has already been disposed. |
T:System.InvalidOperationException | Adding a participant would cause the barrier's participant count to exceed 32,767.-or-The method was invoked from within a post-phase action. |
Definition at line 142 of file Barrier.cs.
◆ AddParticipants()
long System.Threading.Barrier.AddParticipants |
( |
int |
participantCount | ) |
|
Notifies the T:System.Threading.Barrier that there will be additional participants.
- Parameters
-
participantCount | The number of additional participants to add to the barrier. |
- Returns
- The phase number of the barrier in which the new participants will first participate.
- Exceptions
-
T:System.ObjectDisposedException | The current instance has already been disposed. |
T:System.ArgumentOutOfRangeException | participantCount is less than 0.-or-Adding participantCount participants would cause the barrier's participant count to exceed 32,767. |
T:System.InvalidOperationException | The method was invoked from within a post-phase action. |
Definition at line 162 of file Barrier.cs.
◆ Dispose() [1/2]
void System.Threading.Barrier.Dispose |
( |
| ) |
|
Releases all resources used by the current instance of the T:System.Threading.Barrier class.
- Exceptions
-
T:System.InvalidOperationException | The method was invoked from within a post-phase action. |
Implements System.IDisposable.
Definition at line 556 of file Barrier.cs.
◆ Dispose() [2/2]
virtual void System.Threading.Barrier.Dispose |
( |
bool |
disposing | ) |
|
|
protectedvirtual |
Releases the unmanaged resources used by the T:System.Threading.Barrier, and optionally releases the managed resources.
- Parameters
-
disposing | true to release both managed and unmanaged resources; false to release only unmanaged resources. |
Definition at line 569 of file Barrier.cs.
◆ RemoveParticipant()
void System.Threading.Barrier.RemoveParticipant |
( |
| ) |
|
Notifies the T:System.Threading.Barrier that there will be one less participant.
- Exceptions
-
T:System.ObjectDisposedException | The current instance has already been disposed. |
T:System.InvalidOperationException | The barrier already has 0 participants.-or-The method was invoked from within a post-phase action. |
Definition at line 222 of file Barrier.cs.
◆ RemoveParticipants()
void System.Threading.Barrier.RemoveParticipants |
( |
int |
participantCount | ) |
|
Notifies the T:System.Threading.Barrier that there will be fewer participants.
- Parameters
-
participantCount | The number of additional participants to remove from the barrier. |
- Exceptions
-
T:System.ObjectDisposedException | The current instance has already been disposed. |
T:System.ArgumentOutOfRangeException | participantCount is less than 0. |
T:System.InvalidOperationException | The barrier already has 0 participants.-or-The method was invoked from within a post-phase action. -or-current participant count is less than the specified participantCount |
T:System.ArgumentOutOfRangeException | The total participant count is less than the specified participantCount |
Definition at line 235 of file Barrier.cs.
◆ SignalAndWait() [1/6]
void System.Threading.Barrier.SignalAndWait |
( |
| ) |
|
Signals that a participant has reached the barrier and waits for all other participants to reach the barrier as well.
- Exceptions
-
T:System.ObjectDisposedException | The current instance has already been disposed. |
T:System.InvalidOperationException | The method was invoked from within a post-phase action, the barrier currently has 0 participants, or the barrier is signaled by more threads than are registered as participants. |
T:System.Threading.BarrierPostPhaseException | If an exception is thrown from the post phase action of a Barrier after all participating threads have called SignalAndWait, the exception will be wrapped in a BarrierPostPhaseException and be thrown on all participating threads. |
Definition at line 282 of file Barrier.cs.
◆ SignalAndWait() [2/6]
Signals that a participant has reached the barrier and waits for all other participants to reach the barrier, while observing a cancellation token.
- Parameters
-
cancellationToken | The T:System.Threading.CancellationToken to observe. |
- Exceptions
-
T:System.OperationCanceledException | cancellationToken has been canceled. |
T:System.ObjectDisposedException | The current instance has already been disposed. |
T:System.InvalidOperationException | The method was invoked from within a post-phase action, the barrier currently has 0 participants, or the barrier is signaled by more threads than are registered as participants. |
Definition at line 294 of file Barrier.cs.
◆ SignalAndWait() [3/6]
bool System.Threading.Barrier.SignalAndWait |
( |
TimeSpan |
timeout | ) |
|
Signals that a participant has reached the barrier and waits for all other participants to reach the barrier as well, using a T:System.TimeSpan object to measure the time interval.
- Parameters
-
timeout | A T:System.TimeSpan that represents the number of milliseconds to wait, or a T:System.TimeSpan that represents -1 milliseconds to wait indefinitely. |
- Returns
- true if all other participants reached the barrier; otherwise, false.
- Exceptions
-
T:System.ObjectDisposedException | The current instance has already been disposed. |
T:System.ArgumentOutOfRangeException | timeout is a negative number other than -1 milliseconds, which represents an infinite time-out, or it is greater than 32,767. |
T:System.InvalidOperationException | The method was invoked from within a post-phase action, the barrier currently has 0 participants, or the barrier is signaled by more threads than are registered as participants. |
Definition at line 307 of file Barrier.cs.
◆ SignalAndWait() [4/6]
Signals that a participant has reached the barrier and waits for all other participants to reach the barrier as well, using a T:System.TimeSpan object to measure the time interval, while observing a cancellation token.
- Parameters
-
timeout | A T:System.TimeSpan that represents the number of milliseconds to wait, or a T:System.TimeSpan that represents -1 milliseconds to wait indefinitely. |
cancellationToken | The T:System.Threading.CancellationToken to observe. |
- Returns
- true if all other participants reached the barrier; otherwise, false.
- Exceptions
-
T:System.OperationCanceledException | cancellationToken has been canceled. |
T:System.ObjectDisposedException | The current instance has already been disposed. |
T:System.ArgumentOutOfRangeException | timeout is a negative number other than -1 milliseconds, which represents an infinite time-out. |
T:System.InvalidOperationException | The method was invoked from within a post-phase action, the barrier currently has 0 participants, or the barrier is signaled by more threads than are registered as participants. |
Definition at line 323 of file Barrier.cs.
◆ SignalAndWait() [5/6]
bool System.Threading.Barrier.SignalAndWait |
( |
int |
millisecondsTimeout | ) |
|
Signals that a participant has reached the barrier and waits for all other participants to reach the barrier as well, using a 32-bit signed integer to measure the timeout.
- Parameters
-
millisecondsTimeout | The number of milliseconds to wait, or F:System.Threading.Timeout.Infinite(-1) to wait indefinitely. |
- Returns
- if all participants reached the barrier within the specified time; otherwise false.
- Exceptions
-
T:System.ObjectDisposedException | The current instance has already been disposed. |
T:System.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out. |
T:System.InvalidOperationException | The method was invoked from within a post-phase action, the barrier currently has 0 participants, or the barrier is signaled by more threads than are registered as participants. |
T:System.Threading.BarrierPostPhaseException | If an exception is thrown from the post phase action of a Barrier after all participating threads have called SignalAndWait, the exception will be wrapped in a BarrierPostPhaseException and be thrown on all participating threads. |
Definition at line 342 of file Barrier.cs.
◆ SignalAndWait() [6/6]
bool System.Threading.Barrier.SignalAndWait |
( |
int |
millisecondsTimeout, |
|
|
CancellationToken |
cancellationToken |
|
) |
| |
Signals that a participant has reached the barrier and waits for all other participants to reach the barrier as well, using a 32-bit signed integer to measure the timeout, while observing a cancellation token.
- Parameters
-
millisecondsTimeout | The number of milliseconds to wait, or F:System.Threading.Timeout.Infinite(-1) to wait indefinitely. |
cancellationToken | The T:System.Threading.CancellationToken to observe. |
- Returns
- if all participants reached the barrier within the specified time; otherwise false
- Exceptions
-
T:System.OperationCanceledException | cancellationToken has been canceled. |
T:System.ObjectDisposedException | The current instance has already been disposed. |
T:System.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out. |
T:System.InvalidOperationException | The method was invoked from within a post-phase action, the barrier currently has 0 participants, or the barrier is signaled by more threads than are registered as participants. |
Definition at line 358 of file Barrier.cs.
◆ CurrentPhaseNumber
long System.Threading.Barrier.CurrentPhaseNumber |
|
getset |
Gets the number of the barrier's current phase.
- Returns
- Returns the number of the barrier's current phase.
Definition at line 75 of file Barrier.cs.
◆ ParticipantCount
int System.Threading.Barrier.ParticipantCount |
|
get |
Gets the total number of participants in the barrier.
- Returns
- Returns the total number of participants in the barrier.
Definition at line 63 of file Barrier.cs.
◆ ParticipantsRemaining
int System.Threading.Barrier.ParticipantsRemaining |
|
get |
Gets the number of participants in the barrier that haven’t yet signaled in the current phase.
- Returns
- Returns the number of participants in the barrier that haven’t yet signaled in the current phase.
Definition at line 48 of file Barrier.cs.
The documentation for this class was generated from the following file: