atomic_compare_exchange_weak, atomic_compare_exchange_strong, atomic_compare_exchange_weak_explicit, atomic_compare_exchange_strong_explicit
Da 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) |
Atomicamente compara o valor apontado por
obj com o valor apontado por expected, e se estas forem iguais, substitui o ex-desired (executa ler-modificar-escrever a operação). Caso contrário, carrega o valor real apontado por obj em *expected (executa a operação 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.
Os modelos de memória para a leitura-modificação-gravação e operações de carga são
succ e fail respectivamente. As versões (1-2) usar memory_order_seq_cst por padrão.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.
As formas fracas ((1) e (3)) das funções podem falhar spuriously, isto é, actuar como se *obj != *expected mesmo se eles forem iguais. Quando uma comparação e troca-se em um loop, a versão fraca trará melhor desempenho em algumas plataformas. Quando um fraco comparar-e-troca exigiria um laço e um forte não, o forte é preferível.
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.
Esta é uma função genérica definida para todos os tipos de objectos atómicos.
A é o tipo de um objeto atômico, C é do tipo não-atômica correspondente a A.Original:
This is a função 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 | - | ponteiro para o objeto atômico para testar e 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 | - | ponteiro para o valor esperado para ser encontrado no objeto atómica
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 | - | o valor para armazenar no objeto atômico se for como o esperado
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 | - | a sincronização de memória de ordenação para a leitura-modificação-gravação operação, se a comparação for bem-sucedido. Todos os valores são 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 | - | a sincronização da memória de ordenação para a operação de carregamento se a comparação falhar. Não pode ser memory_order_release ou memory_order_ack_rel e não pode especificar mais forte do que
succ ordenaçãoOriginal: 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
O resultado da comparação: true se
*obj foi igual a *exp, false contrário.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] Veja também
| swaps um valor com o valor de um 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. (função) | |
| C++ documentation for atomic_compare_exchange_weak, atomic_compare_exchange_strong, atomic_compare_exchange_weak_explicit, atomic_compare_exchange_strong_explicit
| |