std::atomic_compare_exchange_weak, std::atomic_compare_exchange_strong, std::atomic_compare_exchange_weak_explicit, std::atomic_compare_exchange_strong_explicit
![]() | 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. |
Definido no cabeçalho <atomic> | ||
template<class T > bool atomic_compare_exchange_weak(std::atomic<T>* obj, | (1) | (desde C++11) |
template<class T > bool atomic_compare_exchange_strong(std::atomic<T>* obj, | (2) | (desde C++11) |
template<class T > bool atomic_compare_exchange_weak_explicit(std::atomic<T>* obj, | (3) | (desde C++11) |
template<class T > bool atomic_compare_exchange_strong_explicit(std::atomic<T>* obj, | (4) | (desde C++11) |
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).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).You can help to correct and verify the translation. Click here for instructions.
succ
e fail
respectivamente. As versões (1-2) usar std::memory_order_seq_cst por padrão.succ
and fail
respectively. The (1-2) versions use std::memory_order_seq_cst by default.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.
You can help to correct and verify the translation. Click here for instructions.
Índice |
[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 | - | o sycnhronization 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 sycnhronization 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 | - | o sycnhronization memória de ordenação para a operação de carga se a comparação falhar. Não pode ser std::memory_order_release ou std::memory_order_ack_rel e não pode especificar mais forte do que succ ordenaçãoOriginal: the memory sycnhronization ordering for the load operation if the comparison fails. Cannot be std::memory_order_release or std::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
*obj
foi igual a *exp
, false contrário.*obj
was equal to *exp
, false otherwise.You can help to correct and verify the translation. Click here for instructions.
[editar]Exceções
[editar]Exemplo
You can help to correct and verify the translation. Click here for instructions.
void append(list* s, node* n){ node* head;do{ head = s->head; n->next = head;}while(! std::atomic_compare_exchange_weak(s->head, head, n));}
[editar]Veja também
atomicamente compara o valor do objeto atômico com não atômica argumento e realiza troca atômica se carga igual ou atômica se não Original: atomically compares the value of the atomic object with non-atomic argument and performs atomic exchange if equal or atomic load if not The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (of std::atomic função pública membro) | |
(C++11) (C++11) | atomicamente substitui o valor do objeto atômico com não atômica argumento e retorna o valor antigo do atômica Original: atomically replaces the value of the atomic object with non-atomic argument and returns the old value of the atomic The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (modelo de função) |
especializada operações atômicas para std :: shared_ptr Original: specializes atomic operations for std::shared_ptr The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (modelo de função) | |
Documentação C para atomic_compare_exchange, atomic_compare_exchange_explicit |