From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- .../reference/global_objects/atomics/index.html | 162 +++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 files/ko/web/javascript/reference/global_objects/atomics/index.html (limited to 'files/ko/web/javascript/reference/global_objects/atomics/index.html') diff --git a/files/ko/web/javascript/reference/global_objects/atomics/index.html b/files/ko/web/javascript/reference/global_objects/atomics/index.html new file mode 100644 index 0000000000..6f155e8272 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/atomics/index.html @@ -0,0 +1,162 @@ +--- +title: Atomics +slug: Web/JavaScript/Reference/Global_Objects/Atomics +translation_of: Web/JavaScript/Reference/Global_Objects/Atomics +--- +
{{JSRef}} {{SeeCompatTable}}
+ +
Atomics 오브젝트는 atomic operations  정적메소드로서 제공됩니다. 다음과 같은 오브젝트와 함께 {{jsxref("SharedArrayBuffer")}} 사용합니다.
+ +

Atomic operations Atomic Module을 인스톨해야합니다. 다른 global objects들과 다르게 Atomic은 constructor가 아닙니다. new operator를 사용하면 안되고 invoke Atomics object 함수로 사용하면됩니다. Atomics의 속성과 함수들은 static입니다.  (as is the case with the {{jsxref("Math")}} object, for example).

+ +

Methods

+ +

Atomic operations

+ +

메모리가 공유되었을때, 멀티쓰레드는 메모리안에 같은 데이터들을 읽거나 쓸 수 있습니다.
+ Atomic operations은 예측 가능한 값을 쓰고 읽으며 다음 작업이 시작되기 전에 작업이 완료되고,작업이 중단되지 않도록합니다.

+ +
+
{{jsxref("Atomics.add()")}}
+
Adds a given value at a given position in the array. Returns the old value at that position.
+
{{jsxref("Atomics.and()")}}
+
Computes a bitwise AND at a given position in the array. Returns the old value at that position.
+
{{jsxref("Atomics.compareExchange()")}}
+
Stores a given value at a given position in the array, if it equals a given value. Returns the old value.
+
{{jsxref("Atomics.exchange()")}}
+
Stores a given value at a given position in the array. Returns the old value.
+
+ +
+
{{jsxref("Atomics.load()")}}
+
Returns the value at the given position in the array.
+
{{jsxref("Atomics.or()")}}
+
Computes a bitwise OR at a given position in the array. Returns the old value at that position.
+
{{jsxref("Atomics.store()")}}
+
Stores a given value at the given position in the array. Returns the value.
+
{{jsxref("Atomics.sub()")}}
+
Subtracts a given value at a given position in the array. Returns the old value at that position.
+
{{jsxref("Atomics.xor()")}}
+
Computes a bitwise XOR at a given position in the array. Returns the old value at that position.
+
+ +

Wait and wake

+ +

The wait() and wake() methods are modeled on Linux futexes ("fast user-space mutex") and provide ways for waiting until a certain condition becomes true and are typically used as blocking constructs.

+ +
+
{{jsxref("Atomics.wait()")}}
+
+

Verifies that a given position in the array still contains a given value and sleeps awaiting or times out. Returns either "ok", "not-equal", or "timed-out". If waiting is not allowed in the calling agent then it throws an Error exception (most browsers will not allow wait() on the browser's main thread).

+
+
{{jsxref("Atomics.wake()")}}
+
Wakes up some agents that are sleeping in the wait queue on the given array position. Returns the number of agents that were woken up.
+
{{jsxref("Atomics.isLockFree()", "Atomics.isLockFree(size)")}}
+
+

An optimization primitive that can be used to determine whether to use locks or atomic operations. Returns true, if an atomic operation on arrays of the given element size will be implemented using a hardware atomic operation (as opposed to a lock). Experts only.

+
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Shared Memory', '#AtomicsObject', 'Atomics')}}{{Spec2('Shared Memory')}}Initial definition.
{{SpecName('ESDraft')}}{{Spec2('ESDraft')}} 
+ +

Browser compatibility

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatNo}} [2]{{CompatNo}}{{CompatGeckoDesktop("46")}} [1] [3]{{CompatNo}}{{CompatNo}}{{CompatNo}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("46")}} [1]{{CompatNo}}{{CompatNo}}{{CompatNo}}
+
+ +

[1] This feature is 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

+ +

Compatibility notes

+ +

[3] The Shared memory specification is still stabilizing. Prior to SpiderMonkey 48 {{geckoRelease(48)}}, the latest API names and semantics weren't implemented yet. The changes between Firefox version 46 and version 48 are:

+ + + +

See also

+ + -- cgit v1.2.3-54-g00ecf