|
VLink 2.0.0
A high-performance communication middleware
|
DAG-based task graph with condition branching, cycle detection, and DOT export. 更多...
#include <functional>#include <memory>#include <string>#include <unordered_set>#include <utility>#include <vector>#include "./macros.h"#include "./traits.h"类 | |
| class | vlink::GraphTask |
| Node in a directed acyclic task graph supporting condition branching and parallel execution. 更多... | |
命名空间 | |
| namespace | vlink |
类型定义 | |
| using | vlink::GraphTaskPtr = std::shared_ptr<GraphTask> |
DAG-based task graph with condition branching, cycle detection, and DOT export.
GraphTask implements a directed acyclic graph (DAG) of work units. Tasks define their dependencies by calling precede() (this task must finish before the target) or succeed() (the target must finish before this task). The entire graph is then submitted to any MessageLoop, MultiLoop or ThreadPool via execute().
Task types:
| Factory | Callback signature | Use case |
|---|---|---|
create(callback) | void() | Regular work task |
create_condition(callback) | int() | Branch selector (returns branch id) |
Condition task: A condition task returns an integer selecting which successor sub-graph to activate. All other successors are skipped. This enables if/switch style DAG branching.
Execution policies:
| Policy | Behaviour |
|---|---|
kPolicyOnce | Task runs exactly once per execute() call (default) |
kPolicyMultiple | Task may run multiple times in one execute() pass |
kPolicyWaitAll | Task waits for all predecessors before running (default DAG rule) |
Operator syntax for building graphs:
execute() traverses the reachable sub-graph and dispatches all ready tasks to the engine.has_cycle() detects cycles using DFS; cycles cause undefined behaviour at runtime.export_to_dot() produces a Graphviz DOT string for visualisation.