You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<spanclass="n">executor</span><spanclass="p">.</span><spanclass="n">wait_for_all</span><spanclass="p">();</span><spanclass="c1">// wait for all tasks to finish</span></pre><asideclass="m-note m-info"><h4>Note</h4><p>Asynchronous tasks created from an executor does not belong to any taskflows.</p></aside></section><sectionid="LaunchAsynchronousTasksFromAnSubflow"><h2><ahref="#LaunchAsynchronousTasksFromAnSubflow">Launch Asynchronous Tasks from a Subflow</a></h2><p>You can launch asynchronous tasks from a subflow (<ahref="classtf_1_1Subflow.html" class="m-doc">tf::<wbr/>Subflow</a>) using <ahref="classtf_1_1Subflow.html#a70681068507b224a96df69cc1f3168f1" class="m-doc">tf::<wbr/>Subflow::<wbr/>async</a>. Asynchronous tasks created from a subflow are, and <em>only</em>, used with <em>join</em> (<ahref="classtf_1_1Subflow.html#a59fcac1323e70d920088dd37bd0be245" class="m-doc">tf::<wbr/>Subflow::<wbr/>join</a>) to describe independent tasks that are dynamically spawned during the execution of that subflow. When the subflow joins, all asynchronous tasks are guaranteed to finish. The following code creates 100 asynchronous tasks from a subflow, and these asynchronous tasks will complete by the time the subflow joins.</p><preclass="m-code"><spanclass="n">tf</span><spanclass="o">::</span><spanclass="n">Taskflow</span><spanclass="n">taskflow</span><spanclass="p">;</span>
78
+
<spanclass="n">executor</span><spanclass="p">.</span><spanclass="n">wait_for_all</span><spanclass="p">();</span><spanclass="c1">// wait for all tasks to finish</span></pre><asideclass="m-note m-info"><h4>Note</h4><p>Asynchronous tasks created from an executor does not belong to any taskflows.</p></aside><p>You can name an asynchronous task to facilitate profiling by using the methods <ahref="classtf_1_1Executor.html#a51acee1670e9f246c7ccd7f6a63f1524" class="m-doc">tf::<wbr/>Executor::<wbr/>named_async</a> and <ahref="classtf_1_1Executor.html#a1febfaa7a99cac8466263c58fd2a7c06" class="m-doc">tf::<wbr/>Executor::<wbr/>named_silent_async</a>.</p><preclass="m-code"><spanclass="n">tf</span><spanclass="o">::</span><spanclass="n">Future</span><spanclass="o"><</span><spanclass="kt">void</span><spanclass="o">></span><spanclass="n">future</span><spanclass="o">=</span><spanclass="n">executor</span><spanclass="p">.</span><spanclass="n">named_async</span><spanclass="p">(</span><spanclass="s">"name of the task"</span><spanclass="p">,</span><spanclass="p">[](){});</span>
79
+
<spanclass="n">executor</span><spanclass="p">.</span><spanclass="n">silent_named_async</span><spanclass="p">(</span><spanclass="s">"another name of the task"</span><spanclass="p">,</span><spanclass="p">[](){});</span></pre></section><sectionid="LaunchAsynchronousTasksFromAnSubflow"><h2><ahref="#LaunchAsynchronousTasksFromAnSubflow">Launch Asynchronous Tasks from a Subflow</a></h2><p>You can launch asynchronous tasks from a subflow (<ahref="classtf_1_1Subflow.html" class="m-doc">tf::<wbr/>Subflow</a>) using <ahref="classtf_1_1Subflow.html#a70681068507b224a96df69cc1f3168f1" class="m-doc">tf::<wbr/>Subflow::<wbr/>async</a>. Asynchronous tasks created from a subflow are, and <em>only</em>, used with <em>join</em> (<ahref="classtf_1_1Subflow.html#a59fcac1323e70d920088dd37bd0be245" class="m-doc">tf::<wbr/>Subflow::<wbr/>join</a>) to describe independent tasks that are dynamically spawned during the execution of that subflow. When the subflow joins, all asynchronous tasks are guaranteed to finish. The following code creates 100 asynchronous tasks from a subflow, and these asynchronous tasks will complete by the time the subflow joins.</p><preclass="m-code"><spanclass="n">tf</span><spanclass="o">::</span><spanclass="n">Taskflow</span><spanclass="n">taskflow</span><spanclass="p">;</span>
<spanclass="n">executor</span><spanclass="p">.</span><spanclass="n">run</span><spanclass="p">(</span><spanclass="n">taskflow</span><spanclass="p">).</span><spanclass="n">wait</span><spanclass="p">();</span></pre><p>Creating asynchronous tasks from a subflow allows users to describe, for example, recursive algorithms that define only division without conquering or merging (e.g., parallel quick sort).</p><asideclass="m-note m-warning"><h4>Attention</h4><p>You should only create asynchronous tasks from a joined subflow. Launching asynchronous tasks from a detached subflow results in undefined behavior.</p></aside></section>
106
+
<spanclass="n">executor</span><spanclass="p">.</span><spanclass="n">run</span><spanclass="p">(</span><spanclass="n">taskflow</span><spanclass="p">).</span><spanclass="n">wait</span><spanclass="p">();</span></pre><p>Creating asynchronous tasks from a subflow allows users to describe, for example, recursive algorithms that define only division without conquering or merging (e.g., parallel quick sort).</p><asideclass="m-note m-warning"><h4>Attention</h4><p>You should only create asynchronous tasks from a joined subflow. Launching asynchronous tasks from a detached subflow results in undefined behavior.</p></aside><p>Similar to <ahref="classtf_1_1Executor.html#a51acee1670e9f246c7ccd7f6a63f1524" class="m-doc">tf::<wbr/>Executor::<wbr/>named_async</a> and <ahref="classtf_1_1Executor.html#a1febfaa7a99cac8466263c58fd2a7c06" class="m-doc">tf::<wbr/>Executor::<wbr/>named_silent_async</a>, you can name an asynchronous task in <ahref="classtf_1_1Subflow.html" class="m-doc">tf::<wbr/>Subflow</a> to facilitate profiling by using the methods <ahref="classtf_1_1Subflow.html#ae528c2de98ec89afc50b8815c0306b5e" class="m-doc">tf::<wbr/>Subflow::<wbr/>named_async</a> and <ahref="classtf_1_1Subflow.html#a3290b8f729c4511f2023199e4c067951" class="m-doc">tf::<wbr/>Subflow::<wbr/>named_silent_async</a>.</p><preclass="m-code"><spanclass="n">taskflow</span><spanclass="p">.</span><spanclass="n">emplace</span><spanclass="p">([](</span><spanclass="n">tf</span><spanclass="o">::</span><spanclass="n">Subflow</span><spanclass="o">&</span><spanclass="n">sf</span><spanclass="p">){</span>
107
+
<spanclass="n">tf</span><spanclass="o">::</span><spanclass="n">Future</span><spanclass="o"><</span><spanclass="kt">void</span><spanclass="o">></span><spanclass="n">future</span><spanclass="o">=</span><spanclass="n">sf</span><spanclass="p">.</span><spanclass="n">named_async</span><spanclass="p">(</span><spanclass="s">"name of the task"</span><spanclass="p">,</span><spanclass="p">[](){});</span>
108
+
<spanclass="n">sf</span><spanclass="p">.</span><spanclass="n">silent_named_async</span><spanclass="p">(</span><spanclass="s">"another name of the task"</span><spanclass="p">,</span><spanclass="p">[](){});</span>
Copy file name to clipboardExpand all lines: docs/annotated.html
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,7 @@ <h1>Classes</h1>
65
65
<li>class <ahref="classtf_1_1cudaTask.html" class="m-doc">cudaTask</a><spanclass="m-doc">handle to a node of the internal CUDA graph</span></li>
66
66
<li>class <ahref="classtf_1_1Executor.html" class="m-doc">Executor</a><spanclass="m-doc">class to create an executor for running a taskflow graph</span></li>
67
67
<li>class <ahref="classtf_1_1FlowBuilder.html" class="m-doc">FlowBuilder</a><spanclass="m-doc">class to build a task dependency graph</span></li>
68
-
<li>class <ahref="classtf_1_1Future.html" class="m-doc">Future</a><spanclass="m-doc">class to access the result of task execution</span></li>
68
+
<li>class <ahref="classtf_1_1Future.html" class="m-doc">Future</a><spanclass="m-doc">class to access the result of an execution</span></li>
69
69
<li>class <ahref="classtf_1_1ObserverInterface.html" class="m-doc">ObserverInterface</a><spanclass="m-doc">The interface class for creating an executor observer.</span></li>
70
70
<li>class <ahref="classtf_1_1Semaphore.html" class="m-doc">Semaphore</a><spanclass="m-doc">class to create a semophore object for building a concurrency constraint</span></li>
71
71
<li>class <ahref="classtf_1_1Subflow.html" class="m-doc">Subflow</a><spanclass="m-doc">class to construct a subflow graph from the execution of a dynamic task</span></li>
0 commit comments