◐ Shell
clean mode source ↗

std::atomic - cppreference.com

Da cppreference.com.

Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.

La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui.

Click here for the English version of this page

<tbody> </tbody>

Elemento definito nell'header

<atomic>

template< class T > struct atomic;

(1) (dal C++11)

template<> struct atomic<Integral>;

(2) (dal C++11)

template< class T > struct atomic<T*>;

(3) (dal C++11)

Ciascun indirizzo completo del modello std::atomic definisce un tipo atomico. Gli oggetti di tipi atomici sono l'unico C + + oggetti che sono liberi da gare di dati, vale a dire, se un thread scrive a un oggetto atomico mentre un altro thread legge da esso, il comportamento è ben definito.

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.

Inoltre, gli accessi agli oggetti atomici può stabilire inter-thread di sincronizzazione e l'ordine non-atomica memoria accessi come specificato da 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.

La libreria standard fornisce specializzazioni completo del modello std::atomic per i seguenti tipi:

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.

1)

Una specializzazione per la bool tipo e il suo nome typedef viene definito che viene trattato come un non-specializzato std::atomic<T> a meno che ha layout standard, costruttore predefinito banale, distruttori banali, e supporta la sintassi di inizializzazione aggregata:

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.

Typedef nome

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>

2)

Specializzazioni e typedef per i tipi integrali, come 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.

Typedef nome

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>

Queste specializzazioni sono layout standard, costruttori predefiniti banali, e distruttori banali. Essi supportano la sintassi di inizializzazione aggregata.

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.

3)

std::atomic<T*> per tutti i tipi di puntatore. Queste specializzazioni sono layout standard, costruttori predefiniti banali, e distruttori banali. Essi sostengono di aggregazione

Original:

std::atomic<T*> for all pointer types. These specializations have standard layout, trivial default constructors, and trivial destructors. They support aggregate

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

inizializzazione sintassi.

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.

Membri funzioni

costruisce un oggetto atomico

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.


(metodo pubblico) [modifica]

memorizza un valore in un oggetto atomico

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.


(metodo pubblico) [modifica]

controlla se l'oggetto atomico è senza blocchi

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.


(metodo pubblico) [modifica]

(C++11)

sostituisce atomicamente il valore dell'oggetto atomico con un non-atomica argomento

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.


(metodo pubblico) [modifica]

(C++11)

atomicamente ottiene il valore dell'oggetto atomica

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.


(metodo pubblico) [modifica]

carica di un valore da un oggetto atomico

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.


(metodo pubblico) [modifica]

(C++11)

atomicamente sostituito il valore dell'oggetto atomico e ottiene il valore contenuto in precedenza

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.


(metodo pubblico) [modifica]

confronta atomicamente il valore dell'oggetto atomica con non-atomica argomento ed esegue lo scambio atomico se il carico uguale o atomico in caso contrario

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.


(metodo pubblico) [modifica]

Funzioni membro specializzati

(C++11)

aggiunge atomicamente l'argomento al valore memorizzato nell'oggetto atomica e ottiene il valore contenuto in precedenza

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.


(metodo pubblico) [modifica]

(C++11)

sottrae atomicamente l'argomento dal valore memorizzato nell'oggetto atomica e ottiene il valore contenuto in precedenza

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.


(metodo pubblico) [modifica]

(C++11)

esegue atomicamente l'AND bit a bit tra l'argomento e il valore dell'oggetto atomico e ottiene il valore contenuto precedentemente

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.


(metodo pubblico) [modifica]

(C++11)

esegue atomicamente l'OR bit a bit tra l'argomento e il valore dell'oggetto atomico e ottiene il valore contenuto precedentemente
(metodo pubblico) [modifica]

(C++11)

esegue atomicamente bitwise XOR tra l'argomento e il valore dell'oggetto atomico e ottiene il valore contenuto precedentemente

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.


(metodo pubblico) [modifica]

incrementa o decrementa il valore atomico di uno

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.


(metodo pubblico) [modifica]

aggiunge, sottrae, o esegue XOR bit per bit AND, OR, con il valore atomico

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.


(metodo pubblico) [modifica]

Note

Ci sono terzi equivalenti funzione di modello per tutte le funzioni membro di std::atomic. Quelle non aderenti funzioni possono essere ulteriormente sovraccaricato per i tipi che non sono specializzazioni di std::atomic, ma sono in grado di garantire atomicità. L'unico questo tipo nella libreria standard è 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.

Vedi anche

il blocco privo di tipo booleano atomica

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) [modifica]