cplusplus
.com
教程
參考
文章
論壇
C++
教程
參考
文章
論壇
參考
C 庫
<cassert> (assert.h)
<cctype> (ctype.h)
<cerrno> (errno.h)
C++11
<cfenv> (fenv.h)
<cfloat> (float.h)
C++11
<cinttypes> (inttypes.h)
<ciso646> (iso646.h)
<climits> (limits.h)
<clocale> (locale.h)
<cmath> (math.h)
<csetjmp> (setjmp.h)
<csignal> (signal.h)
<cstdarg> (stdarg.h)
C++11
<cstdbool> (stdbool.h)
<cstddef> (stddef.h)
C++11
<cstdint> (stdint.h)
<cstdio> (stdio.h)
<cstdlib> (stdlib.h)
<cstring> (string.h)
C++11
<ctgmath> (tgmath.h)
<ctime> (time.h)
C++11
<cuchar> (uchar.h)
<cwchar> (wchar.h)
<cwctype> (wctype.h)
容器
C++11
<array>
<deque>
C++11
<forward_list>
<list>
<map>
<queue>
<set>
<stack>
C++11
<unordered_map>
C++11
<unordered_set>
<vector>
輸入/輸出
<fstream>
<iomanip>
<ios>
<iosfwd>
<iostream>
<istream>
<ostream>
<sstream>
<streambuf>
多執行緒
C++11
<atomic>
C++11
<condition_variable>
C++11
<future>
C++11
<mutex>
C++11
<thread>
其他
<algorithm>
<bitset>
C++11
<chrono>
C++11
<codecvt>
<complex>
<exception>
<functional>
C++11
<initializer_list>
<iterator>
<limits>
<locale>
<memory>
<new>
<numeric>
C++11
<random>
C++11
<ratio>
C++11
<regex>
<stdexcept>
<string>
C++11
<system_error>
C++11
<tuple>
C++11
<type_traits>
C++11
<typeindex>
<typeinfo>
<utility>
<valarray>
<mutex>
類
C++11
adopt_lock_t
C++11
defer_lock_t
C++11
lock_guard
C++11
mutex
C++11
once_flag
C++11
recursive_mutex
C++11
recursive_timed_mutex
C++11
timed_mutex
C++11
try_to_lock_t
C++11
unique_lock
函式
C++11
call_once
C++11
lock
C++11
try_lock
常量
C++11
adopt_lock
C++11
defer_lock
C++11
try_to_lock
參考
<mutex>
標頭檔案
<mutex>
互斥體
包含允許程式碼臨界區併發執行時進行
互斥
(mutex)的設施的標頭檔案,從而明確避免資料競爭。
它包含
互斥體型別
、
鎖型別
和特定的
函式
互斥體型別
是用於保護對程式碼
臨界區
訪問的
可鎖定型別
:
鎖定
一個互斥體可防止其他執行緒鎖定它(獨佔訪問),直到它被
解鎖
:
mutex
、
recursive_mutex
、
timed_mutex
、
recursive_timed_mutex
。
鎖
是透過將其訪問與自身生命週期關聯起來以管理互斥體的物件:
lock_guard
、
unique_lock
。
函式
用於同時鎖定多個互斥體(
try_lock
、
lock
)以及直接阻止特定函式的併發執行(
call_once
)。
類
互斥體
mutex
互斥體類
(類)
recursive_mutex
遞迴互斥體類
(類)
timed_mutex
定時互斥體類
(類)
recursive_timed_mutex
遞迴定時互斥體
(類)
鎖
lock_guard
鎖守衛
(類模板)
unique_lock
唯一鎖
(類模板)
其他型別
once_flag
call_once 的標誌引數型別
(類)
adopt_lock_t
adopt_lock 的型別
(類)
defer_lock_t
defer_lock 的型別
(類)
try_to_lock_t
try_to_lock 的型別
(類)
函式
try_lock
嘗試鎖定多個互斥體
(函式模板)
lock
鎖定多個互斥體
(函式模板)
call_once
呼叫函式一次
(公開成員函式)