0

文档说:“类代表可以等待或取消的并行工作task_group的集合。”

1)。我是否认为任务需要在逻辑上相关(但分解),并且理想情况下您需要在其他地方等待它们来整理结果?

  1. IOW,是否可以使用 task_group 来调度基本上彼此没有关系的异步任务(作为类比:有点像将某些处理活动的每次迭代转储到队列中,然后将其拾取以供另一个线程执行)?他们每个人都只是执行并消失,因此我什至不必等待或取消它们。

(我确实明白,如果我不取消或等待不完整的任务,task_group dtor 会抛出异常。让我们暂时忘记这一点,只关注我是否将它用于正确的目的)。

4

1 回答 1

-1

This page has an explanation on task groups - not bad.

In a nutshell,
use task groups (the concurrency::task_group class or the concurrency::parallel_invoke algorithm) when you want to decompose parallel work into smaller pieces and then wait for those smaller pieces to complete.

于 2014-09-06T05:34:19.050 回答