VLink  2.0.0
A high-performance communication middleware
graph_task.h File Reference

Directed acyclic task graph with condition branching, cycle guard and DOT export. More...

#include <memory>
#include <string>
#include <type_traits>
#include <unordered_set>
#include <utility>
#include <vector>
#include "./functional.h"
#include "./macros.h"
#include "./traits.h"
Include dependency graph for graph_task.h:

Go to the source code of this file.

Classes

class  vlink::GraphTask
 DAG node carrying a callback, predecessor and successor links, and run-time state. More...
 

Namespaces

 

Typedefs

using vlink::GraphTaskPtr = std::shared_ptr< GraphTask >
 Convenience alias for the canonical shared_ptr<GraphTask> handle. More...
 

Detailed Description

Directed acyclic task graph with condition branching, cycle guard and DOT export.

GraphTask is VLink's data-flow primitive: every node carries a callback, a list of predecessors and a list of successors, and is submitted to any engine that exposes post_task / post_task_with_priorityMessageLoop, MultiLoop or ThreadPool. Edges are declared with precede / succeed (Taskflow convention) and a process-wide topology mutex serialises all mutators across every graph instance.

DAG diagram
*               +---+   precede   +---+   precede   +---+
*               | A | ----------> | B | ----------> | C |
*               +-+-+             +-+-+             +-+-+
*                 |     condition   |                 |
*                 v                 v                 v
*              +-----+           +-----+           +-----+
*              | D0  |           | E   |           | F   |
*              +-----+           +-----+           +-----+
*                 ^
*                 |  D0/D1/...   condition task selects which successor branch fires
*              +-----+
*              | D1  |
*              +-----+
* 
Task factories
Factory Callback signature Use case
create(callback) void() Regular work node
create_condition(callback) int() Branch selector (return value picks)
Execution policies
Policy Behaviour
kPolicyOnce Runs exactly once per execute pass (default)
kPolicyMultiple Runs multiple times within one execute pass
kPolicyWaitAll Waits for every predecessor before running
Example
vlink::MultiLoop engine(4);
engine.async_run();
auto load = vlink::GraphTask::create("load", [] { load_data(); });
auto proc = vlink::GraphTask::create("proc", [] { process(); });
auto save = vlink::GraphTask::create("save", [] { save_data(); });
// load -- > proc means load->precede(proc); produces execution order load, proc, save.
load-- > proc-- > save;
assert(!load->has_cycle());
load->execute(&engine);