Thread support library
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
C++ includes built-in support for threads, mutual exclusion, condition variables, and futures.
目录 |
[编辑] 。主题。
Threads enable programs to execute across several processor cores.
| Defined in header
<thread> | |
| (C++11) |
管理一个单独的线程 Original: manages a separate thread The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (类) |
Functions managing the current thread | |
| Defined in namespace
this_thread | |
| (C++11) |
suggests that the implementation reschedule execution of threads (函数) |
| (C++11) |
返回当前线程的线程ID Original: returns the thread id of the current thread The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) |
| (C++11) |
停止执行当前线程的指定的持续时间 Original: stops the execution of the current thread for a specified time duration The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) |
| (C++11) |
stops the execution of the current thread until a specified time point (函数) |
[编辑] 。相互排斥。
Mutual exclusion algorithms prevent multiple threads from simultaneously accessing shared resources. This prevents data races and provides support for synchronization between threads.
| Defined in header
<mutex> | |
| (C++11) |
提供了基本的相互排斥的设施 Original: provides basic mutual exclusion facility The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (类) |
| (C++11) |
提供相互排斥设施,实现锁定一个超时 Original: provides mutual exclusion facility which implements locking with a timeout The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (类) |
| (C++11) |
提供了相互排斥的设施,可以由同一个线程递归锁定 Original: provides mutual exclusion facility which can be locked recursively by the same thread The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (类) |
| (C++11) |
提供相互排斥由同一个线程,并实现锁定一个超时可以锁定recursively 的的设施 Original: provides mutual exclusion facility which can be locked recursively by the same thread and implements locking with a timeout The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (类) |
Generic mutex management | |
| (C++11) |
实现了严格的范围为基础的互斥体的所有权包装 Original: implements a strictly scope-based mutex ownership wrapper The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (类模板) |
| (C++11) |
实现可移动的的互斥所有权包装 Original: implements movable mutex ownership wrapper The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (类模板) |
| 标签类型用于指定锁定策略 Original: tag type used to specify locking strategy The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (类) | |
| 标签使用的常量来指定锁定策略 Original: tag constants used to specify locking strategy The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (不变) | |
Generic locking algorithms | |
| (C++11) |
通过重复调用 try_lock试图获得互斥体的所有权 Original: attempts to obtain ownership of mutexes via repeated calls to try_lock The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数模板) |
| (C++11) |
指定的锁互斥体,块,如果有任何无法使用 Original: locks specified mutexes, blocks if any are unavailable The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数模板) |
Original: Call once The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
| (C++11) |
call_once的辅助对象,以确保调用该函数一次 Original: helper object to ensure that call_once invokes the function only once The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (类) |
| (C++11) |
只有一次,即使从多个线程调用调用一个函数 Original: invokes a function only once even if called from multiple threads The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数模板) |
[编辑] 。条件变量。
A condition variable is a synchronization primitive that allows multiple threads to communicate with eachother. It allows some number of threads to wait (possibly with a timeout) for notification from another thread that they may proceed. A condition variable is always associated with a mutex.
| Defined in header
<condition_variable> | |
| (C++11) |
provides a condition variable associated with a std::unique_lock (类) |
| (C++11) |
provides a condition variable associated with any lock type (类) |
| (C++11) |
schedules a call to notify_all to be invoked when this thread is completely finished (函数) |
| (C++11) |
lists the possible results of timed waits on condition variables (枚举) |
[编辑] 。期货。
The standard library provides facilities to obtain values that are returned and to catch exceptions that are thrown by asynchronous tasks (i.e. functions launched in separate threads). These values are communicated in a shared state, in which the asynchronous task may write its return value or store an exception, and which may be examined, waited for, and otherwise manipulated by other threads that hold instances of std::future or std::shared_future that reference that shared state.
| Defined in header
<future> | |
| (C++11) |
存储一个值,该值用于异步检索 Original: stores a value for asynchronous retrieval The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (类模板) |
| (C++11) |
包功能来存储它的返回值的异步检索 Original: packages a function to store its return value for asynchronous retrieval The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (类模板) |
| (C++11) |
等待一个值,该值被设置异步 Original: waits for a value that is set asynchronously The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (类模板) |
| (C++11) |
等待一个异步设置的值(可能是所引用的其他期货) Original: waits for a value (possibly referenced by other futures) that is set asynchronously The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (类模板) |
| (C++11) |
异步运行的功能(可能在一个新的线程),并返回一个std::future,将持有的结果 Original: runs a function asynchronously (potentially in a new thread) and returns a std::future that will hold the result The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数模板) |
| (C++11) |
指定的政策std::async推出 Original: specifies the launch policy for std::async The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (枚举) |
| (C++11) |
指定std::future和std::shared_future进行定时等待的结果 Original: specifies the results of timed waits performed on std::future and std::shared_future The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (枚举) |
Future errors | |
| (C++11) |
报告一个错误相关的期货或承诺 Original: reports an error related to futures or promises The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (类) |
| (C++11) |
确定了未来的错误类别 Original: identifies the future error category The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) |
| (C++11) |
识别未来的错误代码 Original: identifies the future error codes The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (枚举) |

