ConditionVariable Class
Package: @esfx/threading-conditionvariable
Declaration
export declare class ConditionVariable implements Disposable
Constructors
constructor(buffer, byteOffset)
Constructs a new instance of the ConditionVariable
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
SIZE
Declaration
static readonly SIZE = 4;
Methods
[Disposable.dispose]()
Releases the resources associated for this object.
Declaration
[Disposable.dispose](): void;
Returns
close()
Releases the resources associated for this object.
Declaration
close(): void;
Returns
notifyAll()
Notifies all waiting threads.
Declaration
notifyAll(): number;
Returns
The number of threads notified.
notifyOne()
Notifies one waiting thread.
Declaration
notifyOne(): boolean;
Returns
true
if a thread was notified; otherwise, false
.
wait(mutex, condition)
Blocks the current thread until the condition variable is notified.
Declaration
wait(mutex: Lockable, condition?: () => boolean): boolean;
Parameters
- condition
- () => boolean
An optional condition to wait for.
Returns
true
if the condition variable was notified; otherwise, false
.
waitFor(mutex, ms, condition)
Blocks the current thread until the condition variable is notified or after the specified timeout has elapsed.
Declaration
waitFor(mutex: Lockable, ms: number, condition?: () => boolean): boolean;
Parameters
- condition
- () => boolean
An optional condition to wait for.
Returns
true
if the condition variable was notified prior to the timeout period elapsing; otherwise, false
.