Namespaces
Variants

std::mutex:: mutex

From cppreference.net
Concurrency support library
Threads
(C++11)
(C++20)
this_thread namespace
(C++11)
(C++11)
Cooperative cancellation
Mutual exclusion
Generic lock management
Condition variables
(C++11)
Semaphores
Latches and Barriers
(C++20)
(C++20)
Futures
(C++11)
(C++11)
(C++11)
Safe reclamation
Hazard pointers
Atomic types
(C++11)
(C++20)
Initialization of atomic types
(C++11) (deprecated in C++20)
(C++11) (deprecated in C++20)
Memory ordering
(C++11) (deprecated in C++26)
Free functions for atomic operations
Free functions for atomic flags
constexpr mutex ( ) noexcept ;
(1) (自 C++11 起)
mutex ( const mutex & ) = delete ;
(2) (自 C++11 起)
1) 构造互斥量。构造函数完成后互斥量处于未锁定状态。
2) 复制构造函数被删除。

参数

(无)

注释

由于默认构造函数是 constexpr ,静态互斥锁会作为 静态非局部初始化 的一部分进行初始化,该过程在任何动态非局部初始化开始之前完成。这使得在任何静态对象的构造函数中锁定互斥锁都是安全的。

另请参阅

C 文档 关于 mtx_init