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 JsSharedDataBlockWaitersRemarks
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
| Name | Description |
|---|---|
| JsSharedDataBlockWaiters() |
JsSharedDataBlockWaiters()
protected JsSharedDataBlockWaiters()No documentation is available.
Methods
| Name | Description |
|---|---|
| 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).
Parameters
byteIndexint- The index of the location in the block: a multiple of 4 within the block.
countint- The maximum number of waiters to notify;
Int32.MaxValuenotifies 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
byteIndexint- The index of the location in the block: a multiple of
sizewithin the block. expectedValuelong- The expected value of the location (sign-extended for a 32-bit location).
sizeint- The size of the location in bytes: 4 or 8.
timeoutTimeSpan?- The maximum duration of the wait, or
nullto wait until notified. cancellationTokenCancellationToken- 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
byteIndexint- The index of the location in the block: a multiple of
sizewithin the block. expectedValuelong- The expected value of the location (sign-extended for a 32-bit location).
sizeint- The size of the location in bytes: 4 or 8.
timeoutTimeSpan?- The maximum duration of the wait, or
nullto wait until notified. completedAction<bool>- The callback called when the wait completes.
cancellationTokenCancellationToken- 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).