62 lines
9.0 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `Atomics` mod in crate `js_sys`."><meta name="keywords" content="rust, rustlang, rust-lang, Atomics"><title>js_sys::Atomics - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="shortcut icon" href="../../favicon.ico"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><a href='../../js_sys/index.html'><div class='logo-container'><img src='../../rust-logo.png' alt='logo'></div></a><p class='location'>Module Atomics</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#functions">Functions</a></li></ul></div><p class='location'><a href='../index.html'>js_sys</a></p><script>window.sidebarCurrent = {name: 'Atomics', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../../src/js_sys/lib.rs.html#628-767' title='goto source code'>[src]</a></span><span class='in-band'>Module <a href='../index.html'>js_sys</a>::<wbr><a class="mod" href=''>Atomics</a></span></h1><div class='docblock'><p>The <code>Atomics</code> object provides atomic operations as static methods.
They are used with <code>SharedArrayBuffer</code> objects.</p>
<p>The Atomic operations are installed on an <code>Atomics</code> module. Unlike
the other global objects, <code>Atomics</code> is not a constructor. You cannot
use it with a new operator or invoke the <code>Atomics</code> object as a
function. All properties and methods of <code>Atomics</code> are static
(as is the case with the Math object, for example).
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics">MDN documentation</a></p>
</div><h2 id='functions' class='section-header'><a href="#functions">Functions</a></h2>
<table><tr class='module-item'><td><a class="fn" href="fn.add.html" title='js_sys::Atomics::add fn'>add</a></td><td class='docblock-short'><p>The static <code>Atomics.add()</code> method adds a given value at a given
position in the array and returns the old value at that position.
This atomic operation guarantees that no other write happens
until the modified value is written back.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.and.html" title='js_sys::Atomics::and fn'>and</a></td><td class='docblock-short'><p>The static <code>Atomics.and()</code> method computes a bitwise AND with a given
value at a given position in the array, and returns the old value
at that position.
This atomic operation guarantees that no other write happens
until the modified value is written back.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.compare_exchange.html" title='js_sys::Atomics::compare_exchange fn'>compare_exchange</a></td><td class='docblock-short'><p>The static <code>Atomics.compareExchange()</code> method exchanges a given
replacement value at a given position in the array, if a given expected
value equals the old value. It returns the old value at that position
whether it was equal to the expected value or not.
This atomic operation guarantees that no other write happens
until the modified value is written back.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.exchange.html" title='js_sys::Atomics::exchange fn'>exchange</a></td><td class='docblock-short'><p>The static <code>Atomics.exchange()</code> method stores a given value at a given
position in the array and returns the old value at that position.
This atomic operation guarantees that no other write happens
until the modified value is written back.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.is_lock_free.html" title='js_sys::Atomics::is_lock_free fn'>is_lock_free</a></td><td class='docblock-short'><p>The static <code>Atomics.isLockFree()</code> method is used to determine
whether to use locks or atomic operations. It returns true,
if the given size is one of the <code>BYTES_PER_ELEMENT</code> property
of integer <code>TypedArray</code> types.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.load.html" title='js_sys::Atomics::load fn'>load</a></td><td class='docblock-short'><p>The static <code>Atomics.load()</code> method returns a value at a given
position in the array.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.notify.html" title='js_sys::Atomics::notify fn'>notify</a></td><td class='docblock-short'><p>The static <code>Atomics.notify()</code> method notifies up some agents that
are sleeping in the wait queue.
Note: This operation works with a shared <code>Int32Array</code> only.
If <code>count</code> is not provided, notifies all the agents in the queue.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.notify_with_count.html" title='js_sys::Atomics::notify_with_count fn'>notify_with_count</a></td><td class='docblock-short'><p>Notifies up to <code>count</code> agents in the wait queue.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.or.html" title='js_sys::Atomics::or fn'>or</a></td><td class='docblock-short'><p>The static <code>Atomics.or()</code> method computes a bitwise OR with a given value
at a given position in the array, and returns the old value at that position.
This atomic operation guarantees that no other write happens
until the modified value is written back.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.store.html" title='js_sys::Atomics::store fn'>store</a></td><td class='docblock-short'><p>The static <code>Atomics.store()</code> method stores a given value at the given
position in the array and returns that value.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.sub.html" title='js_sys::Atomics::sub fn'>sub</a></td><td class='docblock-short'><p>The static <code>Atomics.sub()</code> method substracts a given value at a
given position in the array and returns the old value at that position.
This atomic operation guarantees that no other write happens
until the modified value is written back.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.wait.html" title='js_sys::Atomics::wait fn'>wait</a></td><td class='docblock-short'><p>The static <code>Atomics.wait()</code> method verifies that a given
position in an <code>Int32Array</code> still contains a given value
and if so sleeps, awaiting a wakeup or a timeout.
It returns a string which is either &quot;ok&quot;, &quot;not-equal&quot;, or &quot;timed-out&quot;.
Note: This operation only works with a shared <code>Int32Array</code>
and may not be allowed on the main thread.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.wait_with_timeout.html" title='js_sys::Atomics::wait_with_timeout fn'>wait_with_timeout</a></td><td class='docblock-short'><p>Like <code>wait()</code>, but with timeout</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.xor.html" title='js_sys::Atomics::xor fn'>xor</a></td><td class='docblock-short'><p>The static <code>Atomics.xor()</code> method computes a bitwise XOR
with a given value at a given position in the array,
and returns the old value at that position.
This atomic operation guarantees that no other write happens
until the modified value is written back.</p>
</td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "js_sys";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>