Espacios de nombres
Variantes
Acciones

atomic_compare_exchange_weak, atomic_compare_exchange_strong, atomic_compare_exchange_weak_explicit, atomic_compare_exchange_strong_explicit

De cppreference.com
< c‎ | atomic

 
 
Operaciones de biblioteca Atómica
Tipos
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
Macros
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
Funciones
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)
Atómicamente compara el valor apuntado por obj con el valor apuntado por expected, y si estos son iguales, sustituye a la anterior con desired (realiza lectura-modificación-escritura de la operación). De lo contrario, se carga el valor actual al que apunta obj en *expected (realiza la operación de carga) .
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.
Los modelos de memoria para la lectura-modificación-escritura y las operaciones de carga son succ y fail respectivamente. Las versiones (1-2) memory_order_seq_cst utilizar por defecto .
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.
Las formas débiles ((1) y (3)) de las funciones pueden fallar falsamente, es decir, actuar como si *obj != *expected incluso si son iguales. Cuando una comparación y el intercambio se encuentra en un bucle, la versión débil dará un mejor rendimiento en algunas plataformas. Cuando un débil comparación y el intercambio requeriría un lazo y una más fuerte no lo haría, el fuerte es preferible .
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.
Este es un función genérica definida para todos los tipos de objetos atómicos. A es el tipo de un objeto atómico, C es del tipo no-atómico correspondiente a A .
Original:
This is a función genérica 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.

[editar] Parámetros

obj -
puntero al objeto atómico para probar y modificar
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 -
puntero al valor que se espera encontrar en el objeto atómico
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 -
el valor a almacenar en el objeto atómico si es como se esperaba
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 -
la sincronización de la memoria de pedido para la lectura-modificación-escritura de la operación si la comparación tiene éxito. Todos los valores están permitidos .
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 -
la sincronización de la memoria de pedido para la operación de carga si la comparación falla. No puede ser memory_order_release o memory_order_ack_rel y no se puede especificar más fuerte que el ordenamiento succ
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.

[editar] Valor de retorno

El resultado de la comparación: true si *obj era igual a *exp, false lo contrario .
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.

[editar] Ver también

swaps un valor con el valor de un objeto atómico
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.

(función) [edit]
C++ documentation for atomic_compare_exchange_weak, atomic_compare_exchange_strong, atomic_compare_exchange_weak_explicit, atomic_compare_exchange_strong_explicit