美文网首页
对于asio中的io_contextd、executor的理解

对于asio中的io_contextd、executor的理解

作者: 天之彼方_d26a | 来源:发表于2020-10-20 16:54 被阅读0次

executor的概念来源于以下三篇提案:

A Unified Executors Proposal for C++ | P0443R13

P1348R0: An Executor Property for Occupancy of Execution Agents

properties

下面简要的总结如下:

我们正在经历由小型硬件到大型超级计算机等各种硬件加速的网络异步并行计算的优雅组合。当前,硬件多样性比以往任何时候都大,但是C ++程序员对其缺乏令人满意的并行编程工具,这份提案提供了一个控制何时何地进行工作的工具。

这里将工作和工作内容进行了区分:

工作——executor

工作内容——sender、receiver

Executor-执行上下文

Executor表示了在某个执行上下文中执行某个操作的需求。

在异步执行环节中,我们需求保存上次调用时的上下文,并在本次调用时在执行上下文的基础上执行特定的操作。

// obtain an executor

executor auto ex = 执行的上下文

// define our work as a nullary invocable

invocable auto work = []{ cout << "My work" << endl; };

// execute our work via the execute customization point

execution::execute(ex, work);

sender、receiver-具体工作内容

receiver只是具有特定接口和语义的回调

sender代表尚未安排执行的工作,必须在其中添加后续的sender,然后启动任务

相关文章

网友评论

      本文标题:对于asio中的io_contextd、executor的理解

      本文链接:https://www.haomeiwen.com/subject/aumdmktx.html