名前空間
変種
操作

atomic_compare_exchange_weak, atomic_compare_exchange_strong, atomic_compare_exchange_weak_explicit, atomic_compare_exchange_strong_explicit

提供: cppreference.com
< c‎ | atomic

 
 
アトミック操作ライブラリ
タイプ
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
memory_order
atomic_flag
マクロ
Original:
Macros
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ATOMIC_***_LOCK_FREE
ATOMIC_FLAG_INIT
ATOMIC_VAR_INIT
kill_dependency
機能します
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
atomic_flag_test_and_set
atomic_flag_clear
atomic_init
atomic_is_lock_free
atomic_store
atomic_load
atomic_exchange
atomic_compare_exchange
atomic_fetch_add
atomic_fetch_sub
atomic_fetch_or
atomic_fetch_xor
atomic_fetch_and
atomic_thread_fence
atomic_signal_fence
 
Defined in header <stdatomic.h>
_Bool atomic_compare_exchange_strong( volatile A* obj,
                                      C* expected, C desired );
(1)
_Bool atomic_compare_exchange_weak( volatile A *obj,
                                    C* expected, C desired );
(2)
_Bool atomic_compare_exchange_strong_explicit( volatile A* obj,

                                               C* expected, C desired,
                                               memory_order succ,

                                               memory_order fail );
(3)
_Bool atomic_compare_exchange_weak_explicit( volatile A *obj,

                                             C* expected, C desired,
                                             memory_order succ,

                                             memory_order fail );
(4)
アトミックobjが指す値を持つexpectedが指す値を比較して、それらが等しい場合、desired(リード·モディファイ·ライト操作を実行する)で前者に置き換えられます。それ以外の場合は、obj(ロード操作を実行する)に*expectedが指す実際の値をロード.
Original:
Atomically compares the value pointed to by obj with the value pointed to by expected, and if those are equal, replaces the former with desired (performs read-modify-write operation). Otherwise, loads the actual value pointed to by obj into *expected (performs load operation).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
リードモディファイライトのメモリモデルとロード操作はsuccfailそれぞれです。 (1-2)のバージョンでは、デフォルトでmemory_order_seq_cstを使用.
Original:
The memory models for the read-modify-write and load operations are succ and fail respectively. The (1-2) versions use memory_order_seq_cst by default.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
機能の弱形((1)と(3))は、見かけ上失敗が許可されている、すなわち、それらが等しい場合でも*obj != *expectedかのように振る舞う。比較交換がループになっている場合、弱いバージョンでは、いくつかのプラットフォーム上でより良いパフォーマンスを得ることができます。弱い比較交換はループが必要となり、強いものは強いものが好ましくないとすると.
Original:
The weak forms ((1) and (3)) of the functions are allowed to fail spuriously, that is, act as if *obj != *expected even if they are equal. When a compare-and-exchange is in a loop, the weak version will yield better performance on some platforms. When a weak compare-and-exchange would require a loop and a strong one would not, the strong one is preferable.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
これは、すべての原子オブジェクト·タイプに対して定義汎用関数です。 Aアトミックオブジェクトの型である、CAに対応する非原子型で.
Original:
This is a 汎用関数 defined for all atomic object types. A is the type of an atomic object, C is the non-atomic type corresponding to A.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] パラメータ

obj -
テストおよび変更するアトミックオブジェクトへのポインタ
Original:
pointer to the atomic object to test and modify
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
expected -
不可分なオブジェクトで発見されることが期待値へのポインタ
Original:
pointer to the value expected to be found in the atomic object
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
desired -
それが期待どおりにされている場合、値はアトミックオブジェクトに格納する
Original:
the value to store in the atomic object if it is as expected
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
succ -
比較が成功した場合にメモリの同期化は、リード·モディファイ·ライト操作の順序。すべての値が許可されています.
Original:
the memory synchronization ordering for the read-modify-write operation if the comparison succeeds. All values are permitted.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
fail -
比較が失敗した場合にメモリ同期は、ロード操作の順序。 memory_order_releaseまたはmemory_order_ack_relsuccより強い順序を指定することはできませんすることはできません
Original:
the memory synchronization ordering for the load operation if the comparison fails. Cannot be memory_order_release or memory_order_ack_rel and cannot specify stronger ordering than succ
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 値を返します

比較の結果:true*obj*expに等しかった場合、falseその他のとき.
Original:
The result of the comparison: true if *obj was equal to *exp, false otherwise.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] も参照してください

スワップアトミックオブジェクトの値を持つ値
Original:
swaps a value with the value of an atomic object
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(関数) [edit]
C++ documentation for atomic_compare_exchange_weak, atomic_compare_exchange_strong, atomic_compare_exchange_weak_explicit, atomic_compare_exchange_strong_explicit