javascript / latest / global_objects / atomics / islockfree.html /

Atomics.isLockFree()

The static Atomics.isLockFree() method is used to determine whether the Atomics methods use locks or atomic hardware operations when applied to typed arrays with the given element byte size. It returns false if the given size is not one of the BYTES_PER_ELEMENT property of integer TypedArray types.

Try it

Syntax

Atomics.isLockFree(size)

Parameters

size

The size in bytes to check.

Return value

A true or false value indicating whether the operation is lock free.

Examples

Using isLockFree

Atomics.isLockFree(1); // true
Atomics.isLockFree(2); // true
Atomics.isLockFree(3); // false
Atomics.isLockFree(4); // true
Atomics.isLockFree(5); // false
Atomics.isLockFree(6); // false
Atomics.isLockFree(7); // false
Atomics.isLockFree(8); // true

Specifications

Browser compatibility

Desktop Mobile Server
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet Deno Node.js
isLockFree
68
60-63
Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of speculative side-channel attacks. This was a temporary removal while mitigations were put in place.
79
16-17
78
57
Support was disabled by default to mitigate speculative execution side-channel attacks (Mozilla Security Blog).
55-57
46-55
No
No
15.2
Like SharedArrayBuffer, Atomics is gated behind COOP/COEP. For more detail, read Making your website "cross-origin isolated" using COOP and COEP.
10.1-11.1
60-63
Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of speculative side-channel attacks. This is intended as a temporary measure until other mitigations are in place.
60-63
Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of speculative side-channel attacks. This is intended as a temporary measure until other mitigations are in place.
57
Support was disabled by default to mitigate speculative execution side-channel attacks (Mozilla Security Blog).
55-57
46-55
No
15.2
Like SharedArrayBuffer, Atomics is gated behind COOP/COEP. For more detail, read Making your website "cross-origin isolated" using COOP and COEP.
10.3-11.3
No
Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of speculative side-channel attacks. This is intended as a temporary measure until other mitigations are in place.
1.0
8.10.0

See also

© 2005–2022 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/isLockFree