This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.
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.
Atomics.isLockFree(size)
size
A Boolean
indicating whether the operation is lock free.
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
Specification | Status | Comment |
---|---|---|
ECMAScript Shared Memory and Atomics The definition of 'Atomics.isLockFree' in that specification. | Draft | Initial definition. |
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | No support [2] | No support | 52 (52) [1] | No support | No support | No support |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | No support | No support | 52.0 (52) [1] | No support | No support | No support |
[1] In Firefox version 46 until version 51, this feature was disabled by a preference setting. In about:config, set javascript.options.shared_memory
to true
.
[2] The implementation is under development and needs these runtime flags: --js-flags=--harmony-sharedarraybuffer --enable-blink-feature=SharedArrayBuffer
© 2005–2017 Mozilla Developer Network and individual 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