Comments (3)
Creating tasks within tasks is not supported by transwarp (unless you're using a separate executor but it still feels somewhat hacky). What is encouraged instead is to construct a graph of tasks where your current "sub_task" would be one of the parents to "main_task". Makes it much easier to reason about your tasks and their inter-dependencies. Does that make sense?
from transwarp.
Do you have some ideas in mind about this hacky executor ?
In my case I already have a codebase, and it will be hard to put every tasks in a single function.
I will try to dedicate time next weeks to clone the repo and add features like the support of subgraph, subtask. As you know well the code do you think it's possible ?
from transwarp.
To make your code above work you need to use a separate executor, e.g.:
tw::parallel main_exec{2};
tw::parallel exec{2};
auto main_task = tw::make_task(tw::wait, [&exec]{
std::vector<int> vec = {1, 2, 3, 4, 5, 6, 7};
auto sub_task = tw::for_each(exec, vec.begin(), vec.end(), [](int& x){ x *= 2; });
sub_task->wait();
});
main_task->schedule(main_exec);
Adding some sort of subgraph support to transwarp doesn't really make sense. With transwarp you can build up graphs and that's it. Sure, you can create another graph within a task. I wouldn't call that a subgraph tho. A task is generic, it can do whatever.
from transwarp.
Related Issues (20)
- Fix appveyor build for C++17
- Schedule the same graph again HOT 1
- Control lifetime of task results HOT 11
- `listener` and `executor` use `itask` HOT 4
- Merge `node` into `itask` HOT 3
- Measure unit test coverage
- Set up clang-tidy
- Add support for C++11 on master branch HOT 1
- Add transwarp to conan repo
- Add transwarp to vcpkg repo HOT 2
- Problem compiling wait_any task HOT 1
- std::result_of removed in C++20 HOT 1
- Transwarp doesn't seem to be fully move aware HOT 3
- if graph final have many leaf tasks, can transwatp get the final result? HOT 4
- Project doesn't install anything HOT 1
- Tasks are not executed HOT 5
- store parallel executor as a member variable causing crash HOT 2
- readability and interface HOT 1
- next() method documented but does not exist HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from transwarp.