Manoj Rao bio photo

Manoj Rao

Your Average Common Man

Email Twitter Github

I am experimenting with different tasking systems to meet a certain need for my current project. The requirements themselves are nothing unusual to expect from a tasking system. The only significant piece of this requirement is that the we have to chain the results from a preceding task and feed it as an input to a new task. This post may not actually address/implement this requirement but I will simply log my experience with a tasking system I experimented with.

Taskflow is an open source library which “…helps you quickly write parallel and heterogeneous task programs…”. What caught me by surprise is the composition of tasks that this framework allows for. Consider the following code taken from the examples:

  // f4: f3_module_task -> f2_module_task
  tf::Taskflow f4; 
  f4.name("F4");
  auto f3_module_task = f4.composed_of(f3);
  auto f2_module_task = f4.composed_of(f2);
  f3_module_task.precede(f2_module_task);

Effectively, f4 is a taskflow which is composed of a couple of other similar taskflow objects f2 and f3. Additionally, f3 precedes f2.

Further, f2 and f3 are themselves composed of other taskflow objects and so on.

It is easier to visualize this hierarchy and to do this taskflow supports dumping dotviz code to an output stream such as stdout. To achieve this you can simply dump as shown:

f4.dump(std::cout);

The examples also show

  executor.run_until(
    f4, 
    [iter = 1] () mutable { std::cout << '\n'; return iter-- == 0; }, 
    [](){ std::cout << "First run_until finished\n"; }
  ).get();

  executor.run_until(
    f4, 
    [iter = 2] () mutable { std::cout << '\n'; return iter-- == 0; }, 
    [](){ std::cout << "Second run_until finished\n"; }
  );

  executor.run_until(
    f4, 
    [iter = 3] () mutable { std::cout << '\n'; return iter-- == 0; }, 
    [](){ std::cout << "Third run_until finished\n"; }
  ).get();

Bring Your Own Cause

If you think any info here has remotely helped you consider dropping a penny for this cause, just click me . You can visit https://www.bbc.com/news/world-asia-india-52672764 Unfortunately, there are plenty of sad things happening all over the world, if you have a different cause or charity you'd rather support please do. And if you did make a donation, please drop a note to me (annotated) or leave a comment here (anonymous is OK!) and I will use that as motivation to write more useful content here.

If you like topics such as this then please consider subscribing to my podcast. I talk to some of the stalwarts in tech and ask them what their favorite productivity hacks are:

Available on iTunes Podcast

Visit Void Star Podcast’s page on iTunes Podcast Portal. Please Click ‘Subscribe’, leave a comment.

Get it iTunes