1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | import { CancellationToken } from "./cancellation";
|
8 | import { Cancelable } from "@esfx/cancelable";
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | export declare class Barrier {
|
14 | private _isExecutingPostPhaseAction;
|
15 | private _postPhaseAction;
|
16 | private _phaseNumber;
|
17 | private _participantCount;
|
18 | private _remainingParticipants;
|
19 | private _waiters;
|
20 | |
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | constructor(participantCount: number, postPhaseAction?: (barrier: Barrier) => void | PromiseLike<void>);
|
27 | /**
|
28 | * Gets the number of the Barrier's current phase.
|
29 | */
|
30 | get currentPhaseNumber(): number;
|
31 | /**
|
32 | * Gets the total number of participants in the barrier.
|
33 | */
|
34 | get participantCount(): number;
|
35 | /**
|
36 | * Gets the number of participants in the barrier that haven't yet signaled in the current phase.
|
37 | */
|
38 | get remainingParticipants(): number;
|
39 | /**
|
40 | * Notifies the Barrier there will be additional participants.
|
41 | *
|
42 | * @param participantCount The number of additional participants.
|
43 | */
|
44 | add(participantCount?: number): void;
|
45 | /**
|
46 | * Notifies the Barrier there will be fewer participants.
|
47 | *
|
48 | * @param participantCount The number of participants to remove.
|
49 | */
|
50 | remove(participantCount?: number): void;
|
51 | /**
|
52 | * Signals that a participant has reached the barrier and waits for all other participants
|
53 | * to reach the barrier.
|
54 | *
|
55 | * @param token An optional CancellationToken used to cancel the request.
|
56 | */
|
57 | signalAndWait(token?: CancellationToken | Cancelable): Promise<void>;
|
58 | private _finishPhase;
|
59 | private _nextPhase;
|
60 | private _resolveNextPhase;
|
61 | private _rejectNextPhase;
|
62 | }
|