Directed acyclic task graph with condition branching, cycle guard and DOT export.
更多...
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_priority – MessageLoop, 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
engine.async_run();
load-- > proc-- > save;
assert(!load->has_cycle());
load->execute(&engine);
static std::shared_ptr< GraphTask > create(Callback &&callback, int condition_number=0)
Creates a regular work node.
MessageLoop subclass that forwards every task to an internal ThreadPool.
Definition: multi_loop.h:106