The static Atomics
.isLockFree()
method is used to determine whether to use locks or atomic operations. It returns true
, if the given size is one of the BYTES_PER_ELEMENT property of integer TypedArray types.
Syntax
Atomics.isLockFree(size)
Parameters
size
- The size in bytes to check.
Return value
A Boolean
indicating whether the operation is lock free.
Examples
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); // false
Specifications
Specification | Status | Comment |
---|---|---|
ECMAScript Latest Draft (ECMA-262) The definition of 'Atomics.isLockFree' in that specification. |
Living Standard | Initial definition in ES2017. |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | 60 | 16 | 55 46 — 541 | No | No | 10.1 |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic support | 60 | 60 | ? | 55 46 — 541 | No | No | No |
1. From version 46 until version 54 (exclusive): this feature is behind the javascript.options.shared_memory
preference (needs to be set to true
). To change preferences in Firefox, visit about:config.