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)

表示该函数定义应针对从 同步语句 调用进行优化。

目录

语法

[ [ optimize_for_synchronized ] ]

说明

适用于在函数声明中声明的名称,该声明必须是该函数的首次声明。

表示函数定义应针对从 同步语句 调用进行优化。特别地,它避免序列化那些调用了对多数调用(但非全部调用)具有事务安全性的函数的同步块。

示例

参考文献

  • 事务性内存技术规范 (ISO/IEC TS 19841:2015):
  • 7.6.6 同步块中的优化属性 [dcl.attr.sync]