diff --git a/files/en-us/web/javascript/reference/global_objects/atomics/index.md b/files/en-us/web/javascript/reference/global_objects/atomics/index.md index a1c4a9fb4bbe664..e7d50665472a446 100644 --- a/files/en-us/web/javascript/reference/global_objects/atomics/index.md +++ b/files/en-us/web/javascript/reference/global_objects/atomics/index.md @@ -104,7 +104,9 @@ const sab = new SharedArrayBuffer(1024); const int32 = new Int32Array(sab); ``` -A reading thread is sleeping and waiting on location 0 which is expected to be 0. As long as that is true, it will not go on. However, once the writing thread has stored a new value, it will be notified by the writing thread and return the new value (123). +A reading thread is sleeping and waiting on location 0 because the provided value matches what is stored at the provided index. +The reading thread will not move on until the writing thread has called `Atomics.notify()` on position 0 of the provided typed array. +Note that if, after being woken up, the value of location 0 has not been changed by the writing thread, the reading thread will **not** go back to sleep, but will continue on. ```js Atomics.wait(int32, 0, 0); diff --git a/files/en-us/web/javascript/reference/global_objects/atomics/notify/index.md b/files/en-us/web/javascript/reference/global_objects/atomics/notify/index.md index eb6a92727c16cd0..dd3d6bede9ec91e 100644 --- a/files/en-us/web/javascript/reference/global_objects/atomics/notify/index.md +++ b/files/en-us/web/javascript/reference/global_objects/atomics/notify/index.md @@ -52,9 +52,9 @@ const sab = new SharedArrayBuffer(1024); const int32 = new Int32Array(sab); ``` -A reading thread is sleeping and waiting on location 0 which is expected to be 0. As -long as that is true, it will not go on. However, once the writing thread has stored a -new value, it will be notified by the writing thread and return the new value (123). +A reading thread is sleeping and waiting on location 0 because the provided `value` matches what is stored at the provided `index`. +The reading thread will not move on until the writing thread has called `Atomics.notify()` on position 0 of the provided `typedArray`. +Note that if, after being woken up, the value of location 0 has not been changed by the writing thread, the reading thread will **not** go back to sleep, but will continue on. ```js Atomics.wait(int32, 0, 0); diff --git a/files/en-us/web/javascript/reference/global_objects/atomics/wait/index.md b/files/en-us/web/javascript/reference/global_objects/atomics/wait/index.md index b5894231a7d8368..070c7e49a174bd7 100644 --- a/files/en-us/web/javascript/reference/global_objects/atomics/wait/index.md +++ b/files/en-us/web/javascript/reference/global_objects/atomics/wait/index.md @@ -38,6 +38,10 @@ Atomics.wait(typedArray, index, value, timeout) A string which is either `"ok"`, `"not-equal"`, or `"timed-out"`. +- `"ok"` is returned if woken up by a call to `Atomics.notify()`, **regardless of if the expected value has changed** +- `"not-equal"` is returned immediately if the initial `value` does not equal what is stored at `index` +- `"timed-out"` is returned if a sleeping wait exceeds the specified `timeout` without being woken up by `Atomics.notify()` + ### Exceptions - {{jsxref("TypeError")}} @@ -58,9 +62,9 @@ const sab = new SharedArrayBuffer(1024); const int32 = new Int32Array(sab); ``` -A reading thread is sleeping and waiting on location 0 which is expected to be 0. As -long as that is true, it will not go on. However, once the writing thread has stored a -new value, it will be notified by the writing thread and return the new value (123). +A reading thread is sleeping and waiting on location 0 because the provided `value` matches what is stored at the provided `index`. +The reading thread will not move on until the writing thread has called `Atomics.notify()` on position 0 of the provided `typedArray`. +Note that if, after being woken up, the value of location 0 has not been changed by the writing thread, the reading thread will **not** go back to sleep, but will continue on. ```js Atomics.wait(int32, 0, 0);