Namespaces
Variants

std:: launch

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)
launch
(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
定义于头文件 <future>
enum class launch : /* 未指定 */ {

async = /* 未指定 */ ,
deferred = /* 未指定 */ ,
/* 实现定义 */

} ;
(C++11 起)

std::launch 是一种 BitmaskType 。它指定了通过 std::async 函数执行任务的启动策略。

常量

以下由标准库定义的常量表示单个位:

枚举项 含义
async 任务在不同线程上执行,可能通过先创建并启动该线程实现
deferred 任务在首次请求其结果时于调用线程上执行(惰性求值)

此外,实现允许:

  • 定义额外的位和位掩码,用于指定适用于部分启动策略子集的任务交互限制,以及
  • std::async 的第一个(默认)重载启用这些额外的位掩码。

缺陷报告

以下行为变更缺陷报告被追溯应用于先前发布的C++标准。

缺陷报告 适用范围 发布时的行为 正确行为
LWG 2102 C++11 std::launch 是实现定义的类型 它不是实现定义的

参见

(C++11)
异步运行函数(可能在新线程中)并返回一个持有结果的 std::future
(函数模板)