这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。
静态方法 Atomics
.isLockFree()
用于校验是否能够使用原子操作的TypedArray
的标准字节长度之一. 若该字节长度为可处理的TypedArray标准字节长度之一则返回 true.
TypedArray的标准字节长度参见 BYTES_PER_ELEMENT
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
语法
Atomics.isLockFree(size)
参数
-
size
-
整形.字节长度,通常为
TypedArray.BYTES_PER_ELEMENT
返回值
TypedArray的标准字节长度之一.
示例
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 Atomics.isLockFree(Float64Array.BYTES_PER_ELEMENT
); // false,Atomics方法无法处理Float64Array
Specifications
Specification | Status | Comment |
---|---|---|
Unknown Atomics.isLockFree |
Unknown | Initial definition. |
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.
Update compatibility data on GitHub
Desktop | Mobile | Server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
isLockFree |
Chrome Full support 68
|
Edge No support 16 — 17
|
Firefox Full support 57
|
IE No support No | Opera No support No | Safari No support 10.1 — ? | WebView Android No support 60 — 63
|
Chrome Android No support 60 — 63
|
Firefox Android Full support 57
|
Opera Android No support No | Safari iOS No support No | Samsung Internet Android No support No
|
nodejs Full support 8.10.0 |
Legend
- Full support
- Full support
- No support
- No support
- See implementation notes.
- See implementation notes.
- User must explicitly enable this feature.
- User must explicitly enable this feature.