std::atomic
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. |
| Déclaré dans l'en-tête <atomic>
|
||
template< class T > struct atomic; |
(1) | (depuis C++11) |
template<> struct atomic<Integral>; |
(2) | (depuis C++11) |
template< class T > struct atomic<T*>; |
(3) | (depuis C++11) |
Chaque spécialisation complète du modèle
std::atomic définit un type atomique. Des objets de types atomiques sont les seuls objets C + + qui sont exempts de races de données, c'est, si un thread écrit dans un objet atomique, tandis qu'un autre thread lit de celle-ci, le comportement est bien défini .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.
En outre, les accès aux objets atomiques peuvent établir des inter-thread de synchronisation et de commande non atomique accès à la mémoire tel que spécifié par 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.
La bibliothèque standard fournit des spécialisations à part entière du modèle
std::atomic pour les types suivants: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.
1)
Une spécialisation pour le
bool type et son nom typedef est défini qui est considérée comme une std::atomic<T> non spécialisé, sauf qu'il a mise en page standard, le constructeur par défaut trivial, destructeurs triviales, et prend en charge la syntaxe d'initialisation d'agrégats: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.
Nom de 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>
|
2)
Spécialisations et typedefs pour les types intégraux, comme suit:
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.
| This section is incomplete Reason: better as a table? |
Nom de 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>
|
Ces spécialisations ont présentation standard, les constructeurs par défaut triviales, banales et destructeurs. Ils prennent en charge la syntaxe d'initialisation d'agrégats .
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.
3)
std::atomic<T*> pour tous les types de pointeurs. Ces spécialisations ont présentation standard, les constructeurs par défaut triviales, banales et destructeurs. Ils prennent en charge globaleOriginal:
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.
syntaxe d'initialisation .
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.
Fonctions membres
construit un objet atomique 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. (fonction membre publique) | |
stocke une valeur dans un objet atomique 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. (fonction membre publique) | |
vérifie si l'objet atomique est sans verrou 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. (fonction membre publique) | |
(C++11) |
remplace atomiquement la valeur de l'objet atomique avec un argument non-atomique 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. (fonction membre publique) |
(C++11) |
obtient atomiquement la valeur de l'objet atomique 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. (fonction membre publique) |
charge une valeur d'un objet atomique 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. (fonction membre publique) | |
(C++11) |
atomiquement remplacé, la valeur de l'objet atomique et obtient la valeur détenue précédemment 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. (fonction membre publique) |
compare atomiquement la valeur de l'objet atomique avec un argument non atomique, et réalise un échange atomique s'ils sont égaux, ou un chargement atomique sinon 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. (fonction membre publique) | |
Fonctions membres spécialisés
(C++11) |
ajoute l'argument atomique à la valeur stockée dans l'objet atomique et obtient la valeur détenue précédemment 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. (fonction membre publique) |
(C++11) |
soustrait atomiquement l'argument de la valeur stockée dans l'objet atomique et obtient la valeur détenue précédemment 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. (fonction membre publique) |
(C++11) |
effectue atomique ET bit à bit entre l'argument et la valeur de l'objet atomique et obtient la valeur détenue précédemment 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. (fonction membre publique) |
(C++11) |
effectue un OU binaire atomique entre l'argument et la valeur de l'objet atomique et obtient la valeur détenue précédemment Original: atomically performs bitwise OR 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. (fonction membre publique) |
(C++11) |
effectue atomique bitwise XOR entre l'argument et la valeur de l'objet atomique et obtient la valeur détenue précédemment 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. (fonction membre publique) |
incrémente ou décrémente la valeur atomique par une 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. (fonction membre publique) | |
additionne, soustrait, ou effectue XOR au niveau du bit AND, OR, avec la valeur atomique 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. (fonction membre publique) | |
Notes
Il ya non-membres équivalents de modèles de fonction pour toutes les fonctions membres de
std::atomic. Ces fonctions non-membres peuvent en outre être surchargé pour les types qui ne sont pas des spécialisations de std::atomic, mais sont capables de garantir l'atomicité. Le seul type telle dans la bibliothèque standard est 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.
Voir aussi
(C++11) |
la serrure sans type booléen atomique 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) |