Namespaces
Variants

C++ attribute: optimize_for_synchronized (TM TS)

From cppreference.net
C++ language
General topics
Flow control
Conditional execution statements
Iteration statements (loops)
Jump statements
Functions
Function declaration
Lambda function expression
inline specifier
Dynamic exception specifications ( until C++17* )
noexcept specifier (C++11)
Exceptions
Namespaces
Types
Specifiers
constexpr (C++11)
consteval (C++20)
constinit (C++20)
Storage duration specifiers
Initialization
Expressions
Alternative representations
Literals
Boolean - Integer - Floating-point
Character - String - nullptr (C++11)
User-defined (C++11)
Utilities
Attributes (C++11)
Types
typedef declaration
Type alias declaration (C++11)
Casts
Memory allocation
Classes
Class-specific function properties
Special member functions
Templates
Miscellaneous
Attributes
(C++23)
(C++11) (until C++26)
(C++14)
(C++20)
(C++17)
(C++11)
optimize_for_synchronized
(TM TS)
(C++20)

Gibt an, dass die Funktionsdefinition für den Aufruf aus einer synchronized-Anweisung optimiert werden soll.

Inhaltsverzeichnis

Syntax

[ [ optimize_for_synchronized ] ]

Erklärung

Gilt für den Namen, der in einer Funktionsdeklaration deklariert wird, welcher die erste Deklaration der Funktion sein muss.

Gibt an, dass die Funktionsdefinition für den Aufruf aus einer synchronized-Anweisung optimiert werden soll. Insbesondere vermeidet es die Serialisierung von synchronisierten Blöcken, die einen Aufruf an eine Funktion durchführen, die für die Mehrheit der Aufrufe transaktionssicher ist, aber nicht für alle Aufrufe.

Beispiel

Referenzen

  • Transactional Memory TS (ISO/IEC TS 19841:2015):
  • 7.6.6 Attribut für Optimierung in synchronisierten Blöcken [dcl.attr.sync]