- Class: ManualResetEvent
- Class: AutoResetEvent
- Class: Semaphore
- Class: CountdownEvent
- Class: Barrier
- Class: ReaderWriterLock
- Interface: LockHandle
- Interface: UpgradeableLockHandle
- Class: Deferred
Asynchronously notifies one or more waiting Promises that an event has occurred.
export declare class ManualResetEvent {
constructor(initialState?: boolean);
readonly isSet: boolean;
set(): void;
reset(): void;
wait(token?: CancellationToken): Promise<void>;
}
Initializes a new instance of the ManualResetEvent class.
initialState
<Boolean> A value indicating whether to set the initial state to signaled.
Gets a value indicating whether the event is signaled.
- Returns: <Boolean>
Sets the state of the event to signaled, resolving one or more waiting Promises.
Sets the state of the event to nonsignaled, causing asynchronous operations to pause.
Asynchronously waits for the event to become signaled.
token
<CancellationToken> A CancellationToken used to cancel the request.- Returns: <Promise> A Promise that resolves when the event is signaled, or rejects if the token is canceled.
Asynchronously notifies one or more waiting Promises that an event has occurred.
export declare class AutoResetEvent {
constructor(initialState?: boolean);
set(): void;
reset(): void;
wait(token?: CancellationToken): Promise<void>;
}
Initializes a new instance of the AutoResetEvent class.
initialState
<Boolean> A value indicating whether to set the initial state to signaled.
Sets the state of the event to signaled, resolving one or more waiting Promises. The event is then automatically reset.
Sets the state of the event to nonsignaled, causing asynchronous operations to pause.
Asynchronously waits for the event to become signaled.
token
<CancellationToken> A CancellationToken used to cancel the request.- Returns: <Promise> A Promise that resolves when the event is signaled, or rejects if the token is canceled.
Limits the number of asynchronous operations that can access a resource or pool of resources.
export declare class Semaphore {
constructor(initialCount: number, maxCount?: number);
readonly count: number;
wait(token?: CancellationToken): Promise<void>;
release(count?: number): void;
}
Initializes a new instance of the Semaphore class.
intialCount
<Number> The initial number of entries.maxCount
<Number> The maximum number of entries.
Gets the number of remaining asynchronous operations that can enter the Semaphore.
- Returns: <Number>
Asynchronously waits for the event to become signaled.
token
<CancellationToken> A CancellationToken used to cancel the request.- Returns: <Promise> A Promise that resolves when the event is signaled, or rejects if the token is canceled.
Releases the Semaphore one or more times.
count
<Number> The number of times to release the Semaphore.
An event that is set when all participants have signaled.
export declare class CountdownEvent {
constructor(initialCount: number);
readonly initialCount: number;
readonly remainingCount: number;
add(count?: number): void;
reset(count?: number): void;
signal(count?: number): void;
wait(token?: CancellationToken): Promise<void>;
}
Initializes a new instance of the CountdownEvent class.
initialCount
<Number> The initial participant count.
Gets the number of signals initially required to set the event.
- Returns: <Number>
Gets the number of remaining signals required to set the event.
- Returns: <Number>
Increments the event's current count by one or more.
count
<Number> An optional count specifying the additional number of signals for which the event will wait.
Resets the remaining and initial count to the specified value, or the initial count.
count
<Number> An optional count specifying the number of required signals.
Registers one or more signals with the CountdownEvent, decrementing the remaining count.
count
<Number> An optional count specifying the number of signals to register.
Asynchronously waits for the event to become signaled.
token
<CancellationToken> A CancellationToken used to cancel the request.- Returns: <Promise> A Promise that resolves when the event is signaled, or rejects if the token is canceled.
Enables multiple tasks to cooperatively work on an algorithm through multiple phases.
export declare class Barrier {
constructor(participantCount: number, postPhaseAction?: (barrier: Barrier) => void | PromiseLike<void>);
readonly currentPhaseNumber: number;
readonly participantCount: number;
readonly remainingParticipants: number;
add(participantCount?: number): void;
remove(participantCount?: number): void;
signalAndWait(token?: CancellationToken): Promise<void>;
}
Initializes a new instance of the Barrier class.
participantCount
<Number> The initial number of participants for the barrier.postPhaseAction
<Function> An action to execute between each phase.
Gets the number of the Barrier's current phase.
- Returns: <Number>
Gets the total number of participants in the barrier.
- Returns: <Number>
Gets the number of participants in the barrier that haven't yet signaled in the current phase.
- Returns: <Number>
Notifies the Barrier there will be additional participants.
participantCount
<Number> The number of additional participants.
Notifies the Barrier there will be fewer participants.
participantCount
<Number> The number of participants to remove.
Signals that a participant has reached the barrier and waits for all other participants to reach the barrier.
token
<CancellationToken> A CancellationToken used to cancel the request.- Returns: <Promise> A Promise that resolves when all participants have signaled, or rejects if the token is canceled.
Coordinates readers and writers for a resource.
export declare class ReaderWriterLock {
constructor();
read(token?: CancellationToken): Promise<LockHandle>;
upgradeableRead(token?: CancellationToken): Promise<UpgradeableLockHandle>;
write(token?: CancellationToken): Promise<LockHandle>;
}
Initializes a new instance of the ReaderWriterLock class.
Asynchronously waits for and takes a read lock on a resource.
token
<CancellationToken> A CancellationToken used to cancel the request.- Returns: <Promise> A Promise that resolves with a LockHandle when the lock is taken, or rejects if the token is canceled.
Asynchronously waits for and takes a read lock on a resource that can later be upgraded to a write lock.
token
<CancellationToken> A CancellationToken used to cancel the request.- Returns: <Promise> A Promise that resolves with a LockHandle when the lock is taken, or rejects if the token is canceled.
Asynchronously waits for and takes a write lock on a resource.
token
<CancellationToken> A CancellationToken used to cancel the request.- Returns: <Promise> A Promise that resolves with a LockHandle when the lock is taken, or rejects if the token is canceled.
An object used to release a held lock.
export interface LockHandle {
release(): void;
}
Releases the lock.
An object used to release a held lock or upgrade to a write lock.
export interface UpgradeableLockHandle {
upgrade(token?: CancellationToken): Promise<LockHandle>;
}
Upgrades the lock to a write lock.
token
<CancellationToken> A CancellationToken used to cancel the request.- Returns: <Promise> A Promise that resolves with a LockHandle when the lock is taken, or rejects if the token is canceled.
Encapsulates a Promise and exposes its resolve and reject callbacks.
export declare class Deferred<T> {
constructor();
readonly promise: Promise<T>;
resolve(value?: PromiseLike<T> | T): void;
reject(reason: any): void;
}
Initializes a new instance of the Deferred class.
Gets the promise.
- Returns: <Promise>
Resolves the promise.
value
<any
> The value used to resolve the promise.
Rejects the promise.
reason
<any
> The reason the promise was rejected.