JsSharedDataBlockWaiters Class

The waiters of a JsSharedDataBlock whose memory is shared with another runtime that has its own waiters, such as a shared WebAssembly memory (the memory.atomic.wait32 and memory.atomic.notify instructions use the waiters of the WebAssembly runtime). Atomics.wait, Atomics.waitAsync and Atomics.notify use them instead of the waiter lists of the engines, so that the waiters of both runtimes are notified by both of them.

public abstract class JsSharedDataBlockWaiters

Remarks

The engine checks the value of the location before it calls JsSharedDataBlockWaiters.Wait or JsSharedDataBlockWaiters.WaitAsync: when another agent changes it before the waiter is added, the waiter completes as if it was notified.

See also

Constructors

NameDescription
JsSharedDataBlockWaiters()

JsSharedDataBlockWaiters()

protected JsSharedDataBlockWaiters()

No documentation is available.

Methods

NameDescription
Notify(int, int)Notifies the waiters of a location of the block (Atomics.notify).
Wait(int, long, int, TimeSpan?, CancellationToken)Blocks the calling thread until the waiter of a location of the block is notified, when the location contains expectedValue (Atomics.wait).
WaitAsync(int, long, int, TimeSpan?, Action<bool>, CancellationToken)Adds an asynchronous waiter of a location of the block (Atomics.waitAsync), when the location contains expectedValue: it is added when the method returns, so that a notification that follows notifies it. completed is called once, on any thread: with true when the waiter was notified, and with false when the wait timed out or was canceled.

Notify(int, int)

Notifies the waiters of a location of the block (Atomics.notify).

public abstract int Notify(int byteIndex, int count)

Parameters

byteIndex int
The index of the location in the block: a multiple of 4 within the block.
count int
The maximum number of waiters to notify; Int32.MaxValue notifies all of them.

Returns

int The number of waiters notified.

Wait(int, long, int, TimeSpan?, CancellationToken)

Blocks the calling thread until the waiter of a location of the block is notified, when the location contains expectedValue (Atomics.wait).

public abstract bool Wait(int byteIndex, long expectedValue, int size, TimeSpan? timeout, CancellationToken cancellationToken)

Parameters

byteIndex int
The index of the location in the block: a multiple of size within the block.
expectedValue long
The expected value of the location (sign-extended for a 32-bit location).
size int
The size of the location in bytes: 4 or 8.
timeout TimeSpan?
The maximum duration of the wait, or null to wait until notified.
cancellationToken CancellationToken
A token that stops the wait (the limits of the running script).

Returns

bool true when the waiter was notified; false when the wait timed out or was canceled.

WaitAsync(int, long, int, TimeSpan?, Action<bool>, CancellationToken)

Adds an asynchronous waiter of a location of the block (Atomics.waitAsync), when the location contains expectedValue: it is added when the method returns, so that a notification that follows notifies it. completed is called once, on any thread: with true when the waiter was notified, and with false when the wait timed out or was canceled.

public abstract bool WaitAsync(int byteIndex, long expectedValue, int size, TimeSpan? timeout, Action<bool> completed, CancellationToken cancellationToken)

Parameters

byteIndex int
The index of the location in the block: a multiple of size within the block.
expectedValue long
The expected value of the location (sign-extended for a 32-bit location).
size int
The size of the location in bytes: 4 or 8.
timeout TimeSpan?
The maximum duration of the wait, or null to wait until notified.
completed Action<bool>
The callback called when the wait completes.
cancellationToken CancellationToken
A token that stops the wait: it is canceled when the engine is disposed or when the cancellation token of its options is canceled.

Returns

bool true when the waiter is added; false when the other runtime cannot add more waiters (completed is then not called, and Atomics.waitAsync throws a RangeError).