aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/atomics/islockfree
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/javascript/reference/global_objects/atomics/islockfree
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/atomics/islockfree')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/atomics/islockfree/index.html69
1 files changed, 69 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/atomics/islockfree/index.html b/files/zh-cn/web/javascript/reference/global_objects/atomics/islockfree/index.html
new file mode 100644
index 0000000000..be8b32b587
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/atomics/islockfree/index.html
@@ -0,0 +1,69 @@
+---
+title: Atomics.isLockFree()
+slug: Web/JavaScript/Reference/Global_Objects/Atomics/isLockFree
+translation_of: Web/JavaScript/Reference/Global_Objects/Atomics/isLockFree
+---
+<div>{{JSRef}} {{SeeCompatTable}}</div>
+
+<p>静态方法 <code><strong>Atomics</strong></code><strong><code>.isLockFree()</code></strong> 用于校验是否能够使用原子操作的<code><a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT" title="TypedArray.BYTES_PER_ELEMENT 属性代表了强类型数组中每个元素所占用的字节数。">TypedArray</a></code>的标准字节长度之一. 若该字节长度为可处理的TypedArray标准字节长度之一则返回  <code>true.</code>  TypedArray的标准字节长度参见 <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT">BYTES_PER_ELEMENT</a></p>
+
+<div>{{EmbedInteractiveExample("pages/js/atomics-islockfree.html")}}</div>
+
+
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">Atomics.isLockFree(size)
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>size</code></dt>
+ <dd>整形.字节长度,通常为<a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT" title="TypedArray.BYTES_PER_ELEMENT 属性代表了强类型数组中每个元素所占用的字节数。"><code>TypedArray.BYTES_PER_ELEMENT</code></a></dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<p> {{jsxref("Boolean")}} 是否为能够使用原子操作的<code><a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT" title="TypedArray.BYTES_PER_ELEMENT 属性代表了强类型数组中每个元素所占用的字节数。">TypedArray</a></code>的标准字节长度之一.</p>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: js">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(<code>Float64Array.BYTES_PER_ELEMENT</code>); // false,<code>Atomics方法无法处理Float64Array</code></pre>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('Shared Memory', '#Atomics.isLockFree', 'Atomics.isLockFree')}}</td>
+ <td>{{Spec2('Shared Memory')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+
+
+<p>{{Compat("javascript.builtins.Atomics.isLockFree")}}</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li>{{jsxref("Atomics")}}</li>
+</ul>