Atomics.isLockFree() - JavaScript 编辑
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.
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.
Syntax
Atomics.isLockFree(size)
Parameters
size
- The size in bytes to check.
Return value
A Boolean
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
Specification |
---|
ECMAScript (ECMA-262) The definition of 'Atomics.isLockFree' in that specification. |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论