atomic_compare_exchange_weak, atomic_compare_exchange_strong, atomic_compare_exchange_weak_explicit, atomic_compare_exchange_strong_explicit
De cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Defined in header <stdatomic.h>
|
||
| _Bool atomic_compare_exchange_strong( volatile A* obj, C* expected, C desired ); |
(1) | (desde C11) |
| _Bool atomic_compare_exchange_weak( volatile A *obj, C* expected, C desired ); |
(2) | (desde C11) |
| _Bool atomic_compare_exchange_strong_explicit( volatile A* obj, C* expected, C desired, |
(3) | (desde C11) |
| _Bool atomic_compare_exchange_weak_explicit( volatile A *obj, C* expected, C desired, |
(4) | (desde C11) |
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.
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.
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.
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.
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
succOriginal: 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 succThe 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.
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) | |
| C++ documentation for atomic_compare_exchange_weak, atomic_compare_exchange_strong, atomic_compare_exchange_weak_explicit, atomic_compare_exchange_strong_explicit
| |