VLink  2.0.0
A high-performance communication middleware
graph_task.h 文件参考

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

#include <memory>
#include <string>
#include <type_traits>
#include <unordered_set>
#include <utility>
#include <vector>
#include "./functional.h"
#include "./macros.h"
#include "./traits.h"
graph_task.h 的引用(Include)关系图:

浏览源代码.

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

命名空间

 

类型定义

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

详细描述

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);