◐ Shell
clean mode source ↗

std::atomic – cppreference.com

Aus cppreference.com

<tbody> </tbody>

definiert in Header

<atomic>

template< class T > struct atomic;

(1) (seit C++11)

template<> struct atomic<Integral>;

(2) (seit C++11)

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

(3) (seit C++11)

Jede volle Spezialisierung der std::atomic Vorlage definiert einen atomare Typ. Objekte der Atomtypen sind die einzigen C + +-Objekte, die frei von Race Conditions sind. Das heißt, wenn ein Thread ein atomares Objekt beschreibt während ein anderer Thread daraus liest, ist das Verhalten wohldefiniert .

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.

Darüber hinaus greift auf atomare Objekte können inter-Thread-Synchronisation und damit nicht-atomare Speicher herzustellen Zugriffen durch std::memory_order angegeben .

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.

Die Standard-Bibliothek bietet eine vollständige Spezialisierungen der std::atomic Vorlage für die folgenden Typen:

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)

Eine Spezialisierung der Art bool und seine typedef Namen definiert ist, dass als nicht-spezialisierten std::atomic<T> außer dass es Standard-Layout, trivialen Standardkonstruktor, trivial Destruktoren behandelt und unterstützt insgesamt Initialisierungssyntax:

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 Namen

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)

Spezialisierungen und typedefs für integrale Typen, wie folgt:

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 Namen

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>

Diese Spezialisierungen sind Standard-Layout, trivial standardmäßig Konstruktoren und trivial Destruktoren. Sie unterstützen aggregierte Initialisierungssyntax .

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*> für alle Zeigertypen. Diese Spezialisierungen sind Standard-Layout, trivial standardmäßig Konstruktoren und trivial Destruktoren. Sie unterstützen Aggregat

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.

Initialisierungssyntax .

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.

Member-Funktionen

konstruiert eine atomare Objekt

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.


(öffentliche Elementfunktion) [edit]

speichert einen Wert in einem atomaren Objekt

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.


(öffentliche Elementfunktion) [edit]

prüft, ob der atomare Objektsperre-frei ist

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.


(öffentliche Elementfunktion) [edit]

(C++11)

atomar ersetzt den Wert des atomaren Objekt mit einem nicht-atomaren Argument

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.


(öffentliche Elementfunktion) [edit]

(C++11)

atomar erhält der Wert des atomaren Objekt

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.


(öffentliche Elementfunktion) [edit]

lädt einen Wert von einem atomaren Objekt

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.


(öffentliche Elementfunktion) [edit]

(C++11)

atomar ersetzt den Wert des atomaren Objekt und erhält den Wert zuvor gehaltenen

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.


(öffentliche Elementfunktion) [edit]

atomar vergleicht den Wert des atomaren Objekt mit nicht-elementare Argument und führt atomaren Austausch wenn gleiche oder atomare Last, wenn nicht

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.


(öffentliche Elementfunktion) [edit]

Specialized Member-Funktionen

(C++11)

atomar fügt das Argument zu dem Wert in dem atomaren Objekt gespeichert und erhält den Wert gehalten zuvor

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.


(öffentliche Elementfunktion) [edit]

(C++11)

atomar zieht das Argument aus dem Wert in der atomaren Objekt gespeichert und erhält den Wert zuvor gehaltenen

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.


(öffentliche Elementfunktion) [edit]

(C++11)

atomar ausführt bitweisen UND zwischen dem Argument und dem Wert des atomaren Objekt und erhält den Wert gehalten zuvor

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.


(öffentliche Elementfunktion) [edit]

(C++11)

atomically performs bitwise OR between the argument and the value of the atomic object and obtains the value held previously
(öffentliche Elementfunktion) [edit]

(C++11)

atomar ausführt bitweise XOR zwischen dem Argument und dem Wert des atomaren Objekt und erhält den Wert gehalten zuvor

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.


(öffentliche Elementfunktion) [edit]

erhöht oder vermindert den atomaren Wert um eins

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.


(öffentliche Elementfunktion) [edit]

addieren, subtrahieren, oder führt bitweise AND, OR, XOR mit dem atomaren Wert

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.


(öffentliche Elementfunktion) [edit]

Notes

Es gibt nicht-Member-Funktion Vorlage Äquivalente für alle Member-Funktionen std::atomic. Diese nicht-Member-Funktionen können zusätzlich für Typen, die nicht Spezialisierungen std::atomic, sondern sind in der Lage, um die Unteilbarkeit garantieren überlastet werden. Die einzige dieser Art in der Standard-Bibliothek ist 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.

Siehe auch

Die Lock-freie boolean atomaren Typ

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.


(Klasse) [edit]