std::atomic
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. |
Definido no cabeçalho <atomic>
|
||
template< class T > struct atomic; |
(1) | (desde C++11) |
template<> struct atomic<Integral>; |
(2) | (desde C++11) |
template< class T > struct atomic<T*>; |
(3) | (desde C++11) |
Cada especialização completo do modelo
std::atomic
define um tipo atômico. Objetos de tipos atômicos são o único C + + objetos que estão livres de corridas de dados, isto é, se uma thread escreve a um objeto atômico enquanto outro segmento lê-lo, o comportamento é bem definido.Original:
Each full specialization of the
std::atomic
template defines an atomic type. Objects of atomic types are the only C++ objects that are free from data races; that is, if one thread writes to an atomic object while another thread reads from it, the behavior is well-defined.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.
Além disso, os acessos aos objetos atômicos pode estabelecer inter-thread de sincronização e de memória para não atômica acessos, conforme especificado pelo std::memory_order.
Original:
In addition, accesses to atomic objects may establish inter-thread synchronization and order non-atomic memory accesses as specified by std::memory_order.
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.
A biblioteca padrão oferece especializações completo do modelo
1) std::atomic
para os seguintes tipos:Original:
The standard library provides full specializations of the
std::atomic
template for the following types: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.
Uma especialização para o bool tipo e seu nome typedef está definido que é tratado como um
std::atomic<T>
não especializada, exceto que ele tem um layout padrão, construtor padrão trivial, destruidores triviais, e suporta sintaxe de inicialização de agregação:Original:
One specialization for the type bool and its typedef name is defined that is treated as a non-specialized
std::atomic<T>
except that it has standard layout, trivial default constructor, trivial destructors, and supports aggregate initialization syntax: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.
nome. Typedef
Original: Typedef name The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Full specialization |
std::atomic_bool | std::atomic<bool> |
Especializações e typedefs para tipos integrais, como se segue:
Original:
Specializations and typedefs for integral types, as follows:
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 seção está incompleta Motivo: better as a table? |
nome. Typedef
Original: Typedef name The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Full specialization |
std::atomic_char | std::atomic<char> |
std::atomic_schar | std::atomic<signed char> |
std::atomic_uchar | std::atomic<unsigned char> |
std::atomic_short | std::atomic<short> |
std::atomic_ushort | std::atomic<unsigned short> |
std::atomic_int | std::atomic<int> |
std::atomic_uint | std::atomic<unsigned int> |
std::atomic_long | std::atomic<long> |
std::atomic_ulong | std::atomic<unsigned long> |
std::atomic_llong | std::atomic<long long> |
std::atomic_ullong | std::atomic<unsigned long long> |
std::atomic_char16_t | std::atomic<char16_t> |
std::atomic_char32_t | std::atomic<char32_t> |
std::atomic_wchar_t | std::atomic<wchar_t> |
std::atomic_int_least8_t | std::atomic<int_least8_t> |
std::atomic_uint_least8_t | std::atomic<uint_least8_t> |
std::atomic_int_least16_t | std::atomic<int_least16_t> |
std::atomic_uint_least16_t | std::atomic<uint_least16_t> |
std::atomic_int_least32_t | std::atomic<int_least32_t> |
std::atomic_uint_least32_t | std::atomic<uint_least32_t> |
std::atomic_int_least64_t | std::atomic<int_least64_t> |
std::atomic_uint_least64_t | std::atomic<uint_least64_t> |
std::atomic_int_fast8_t | std::atomic<int_fast8_t> |
std::atomic_uint_fast8_t | std::atomic<uint_fast8_t> |
std::atomic_int_fast16_t | std::atomic<int_fast16_t> |
std::atomic_uint_fast16_t | std::atomic<uint_fast16_t> |
std::atomic_int_fast32_t | std::atomic<int_fast32_t> |
std::atomic_uint_fast32_t | std::atomic<uint_fast32_t> |
std::atomic_int_fast64_t | std::atomic<int_fast64_t> |
std::atomic_uint_fast64_t | std::atomic<uint_fast64_t> |
std::atomic_intptr_t | std::atomic<intptr_t> |
std::atomic_uintptr_t | std::atomic<uintptr_t> |
std::atomic_size_t | std::atomic<size_t> |
std::atomic_ptrdiff_t | std::atomic<ptrdiff_t> |
std::atomic_intmax_t | std::atomic<intmax_t> |
std::atomic_uintmax_t | std::atomic<uintmax_t> |
Essas especializações têm layout padrão, construtores padrão triviais, e destruidores triviais. Eles apóiam sintaxe de inicialização agregado.
3) Original:
These specializations have standard layout, trivial default constructors, and trivial destructors. They support aggregate initialization syntax.
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.
std::atomic<T*>
para todos os tipos de ponteiro. Essas especializações têm layout padrão, construtores padrão triviais, e destruidores triviais. Eles apóiam agregadoOriginal:
std::atomic<T*>
for all pointer types. These specializations have standard layout, trivial default constructors, and trivial destructors. They support aggregateThe 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.
sintaxe de inicialização.
Original:
initialization syntax.
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.
Índice |
[editar] Funções de membro
constrói um objeto atômico Original: constructs 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 pública membro) | |
armazena um valor em um objeto atômico Original: stores a value into 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 pública membro) | |
Verifica se o objeto atômico é lock-livre Original: checks if the atomic object is lock-free The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função pública membro) | |
(C++11) |
atomicamente substitui o valor do objeto atômico com um argumento não-atômica Original: atomically replaces the value of the atomic object with a non-atomic argument The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função pública membro) |
(C++11) |
atomicamente obtém o valor do objecto atómica Original: atomically obtains the value of 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. (função pública membro) |
carrega um valor de um objeto atômico Original: loads a value from 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 pública membro) | |
(C++11) |
atomicamente substituiu o valor do objeto atômico e obtém o valor retido anteriormente Original: atomically replaced the value of the atomic object and obtains the value held previously The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função pública membro) |
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. (função pública membro) |
[editar] Membro funções especializadas
(C++11) |
atomicamente acrescenta o argumento para o valor armazenado no objeto atômico e obtém o valor retido anteriormente Original: atomically adds the argument to the value stored in the atomic object and obtains the value held previously The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função pública membro) |
(C++11) |
atomicamente subtrai o argumento do valor armazenado no objeto atômico e obtém o valor retido anteriormente Original: atomically subtracts the argument from the value stored in the atomic object and obtains the value held previously The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função pública membro) |
(C++11) |
atomicamente executa bit a bit AND entre o argumento eo valor do objeto atômico e obtém o valor retido anteriormente Original: atomically performs bitwise AND between the argument and the value of the atomic object and obtains the value held previously The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função pública membro) |
(C++11) |
atomically performs bitwise OR between the argument and the value of the atomic object and obtains the value held previously (função pública membro) |
(C++11) |
atomicamente executa bit a bit XOR entre o argumento eo valor do objeto atômico e obtém o valor retido anteriormente Original: atomically performs bitwise XOR between the argument and the value of the atomic object and obtains the value held previously The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função pública membro) |
aumenta ou diminui o valor atômico por um Original: increments or decrements the atomic value by one The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função pública membro) | |
soma, subtrai, ou executa XOR bit a bit AND, OR, com o valor atômico Original: adds, subtracts, or performs bitwise AND, OR, XOR with the atomic value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função pública membro) |
[editar] Notas
Há não-membros equivalentes função de modelo para todas as funções de membro de
std::atomic
. Essas funções não-membros poderão ainda ser sobrecarregado para tipos que não são especializações de std::atomic, mas são capazes de garantir a atomicidade. O único tipo como na biblioteca padrão é std::shared_ptr<T>.Original:
There are non-member function template equivalents for all member functions of
std::atomic
. Those non-member functions may be additionally overloaded for types that are not specializations of std::atomic, but are able to guarantee atomicity. The only such type in the standard library is std::shared_ptr<T>.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
(C++11) |
o lock-livre tipo boolean atômica Original: the lock-free boolean atomic type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (classe) |