Skip to content

Commit 2c352b2

Browse files
author
TSUNG-WEI HUANG
committed
added async module task tests
1 parent 173839e commit 2c352b2

8 files changed

Lines changed: 777 additions & 312 deletions

File tree

doxygen/releases/release-3.9.0.dox

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ and enhances exception handling across all task types.
6161
+ removed std::bind from asynchronous tasks to ensure proper constexpr switch
6262
+ added compile-time macros to enable specific features
6363
+ `TF_ENABLE_TASK_POOL` to enable the use of task pool
64+
+ added taskflow execution through asynchronous tasking with tf::make_module_task
6465

6566
@subsection release-3-9-0_utilities Utilities
6667

examples/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ list(APPEND TF_EXAMPLES
22
simple
33
attach_data
44
async
5+
async_module
56
runtime_async
67
dependent_async
78
observer

examples/async.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// The program demonstrates how to create asynchronous task
22
// from an executor and a subflow.
33
#include <taskflow/taskflow.hpp>
4-
#include <taskflow/algorithm/module.hpp>
54

65
int main() {
76

@@ -52,11 +51,6 @@ int main() {
5251

5352
executor.run(taskflow).wait();
5453

55-
// reset the counter and run the taskflow again through async tasking
56-
counter = 0;
57-
executor.async(tf::make_module_task(taskflow)).get();
58-
59-
6054
return 0;
6155
}
6256

examples/async_module.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// This program demonstrates how to launch taskflows using asynchronous tasking.
2+
3+
#include <taskflow/taskflow.hpp>
4+
#include <taskflow/algorithm/module.hpp>
5+
6+
int main() {
7+
8+
tf::Executor executor;
9+
10+
tf::Taskflow A;
11+
tf::Taskflow B;
12+
tf::Taskflow C;
13+
tf::Taskflow D;
14+
15+
A.emplace([](){ printf("Taskflow A\n"); });
16+
B.emplace([](){ printf("Taskflow B\n"); });
17+
C.emplace([](){ printf("Taskflow C\n"); });
18+
D.emplace([](){ printf("Taskflow D\n"); });
19+
20+
// launch the four taskflows using async
21+
printf("launching four taskflows using async ...\n");
22+
executor.async(tf::make_module_task(A));
23+
executor.async(tf::make_module_task(B));
24+
executor.async(tf::make_module_task(C));
25+
executor.async(tf::make_module_task(D));
26+
executor.wait_for_all();
27+
28+
// launch four taskflows with dependencies
29+
printf("launching four taskflows using dependent async ...\n");
30+
auto TA = executor.silent_dependent_async(tf::make_module_task(A));
31+
auto TB = executor.silent_dependent_async(tf::make_module_task(B), TA);
32+
auto TC = executor.silent_dependent_async(tf::make_module_task(C), TB);
33+
auto [TD, FD] = executor.dependent_async(tf::make_module_task(D), TC);
34+
FD.get();
35+
36+
return 0;
37+
}

unittests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ list(APPEND TF_UNITTESTS
2121
test_sort
2222
test_scan
2323
test_find
24-
test_compositions
24+
test_modules
2525
test_traversals
2626
test_pipelines
2727
test_scalable_pipelines

unittests/test_compositions.cpp

Lines changed: 0 additions & 220 deletions
This file was deleted.

0 commit comments

Comments
 (0)