Git Product home page Git Product logo

Comments (3)

bloomen avatar bloomen commented on September 16, 2024

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.

Alex-PLACET avatar Alex-PLACET commented on September 16, 2024

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.

bloomen avatar bloomen commented on September 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.