CountdownEvent Class
Package: @esfx/threading-countdown
Declaration
export declare class CountdownEvent implements Disposable
Constructors
constructor(initialCount)
Constructs a new instance of the CountdownEvent
class
Declaration
constructor(initialCount: number);
Parameters
- initialCount
- number
constructor(buffer, byteOffset)
Constructs a new instance of the CountdownEvent
class
Declaration
constructor(buffer: SharedArrayBuffer, byteOffset?: number);
Parameters
- buffer
- SharedArrayBuffer
- byteOffset
- number
Properties
buffer
Gets the SharedArrayBuffer
for this object.
Declaration
get buffer(): SharedArrayBuffer;
Property Value
byteLength
Gets the number of bytes occupied by this object in its buffer.
Declaration
get byteLength(): number;
Property Value
byteOffset
Gets the byte offset of this object in its buffer.
Declaration
get byteOffset(): number;
Property Value
initialCount
Gets the number of participants initially required to signal the event.
Declaration
get initialCount(): number;
Property Value
isSet
Gets a value indicating whether the event is signaled (all participants are accounted for).
Declaration
get isSet(): boolean;
Property Value
remainingCount
Gets the number of remaining participants required to signal the event.
Declaration
get remainingCount(): number;
Property Value
SIZE
Declaration
static readonly SIZE = 12;
Methods
[Disposable.dispose]()
Releases all resources for this object.
Declaration
[Disposable.dispose](): void;
Returns
add(count)
Adds one or more required participants to the event.
Declaration
add(count?: number): void;
Parameters
- count
- number
Returns
close()
Releases all resources for this object.
Declaration
close(): void;
Returns
reset(count)
Resets the countdown to the specified count.
Declaration
reset(count?: number): void;
Parameters
- count
- number
The new number of participants required. If this is undefined
, the current value of initialCount
is used.
Returns
signal(count)
Signals a participant is ready, decrementing the number of remaining required participants by the provided value.
Declaration
signal(count?: number): boolean;
Parameters
Returns
true
if all participants were accounted for and the event became signaled; otherwise, false
.
tryAdd(count)
Adds one or more required participants to the event if the event is not already signaled.
Declaration
tryAdd(count?: number): boolean;
Parameters
- count
- number
Returns
true
if the participants were added; otherwise, false
.
wait(ms)
Blocks the current thread until the countdown is set.
Declaration
wait(ms?: number): boolean;
Parameters
Returns
true
if the event was signaled before the timeout period elapsed; otherwise, false
.