NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
executor.h File Reference

NodeExecutor — owns per-super-step node invocation. More...

#include <neograph/api.h>
#include <neograph/graph/types.h>
#include <neograph/graph/node.h>
#include <neograph/graph/compiler.h>
#include <neograph/graph/coordinator.h>
#include <neograph/graph/node_cache.h>
#include <neograph/graph/scheduler.h>
#include <asio/thread_pool.hpp>
#include <atomic>
#include <functional>
#include <map>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
Include dependency graph for executor.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  neograph::graph::NodeExecutor
 Stateless-per-call node invocation dispatcher. More...
 

Detailed Description

NodeExecutor — owns per-super-step node invocation.

Extracted from GraphEngine::execute_graph so the three invocation paths that used to be open-coded inside the super-step loop sit behind named methods with their own invariants:

  • run_one_async — single-node path. Handles replay lookup, retry, pending-write recording, state.apply_writes, trace append, and (on NodeInterrupt) a phase=NodeInterrupt checkpoint save via the coordinator. Rethrows the interrupt after the save.
  • run_parallel_async — fan-out via asio::experimental::make_parallel_group. Records per-worker pending writes, captures the first worker exception, and rethrows after every branch has finished. After the barrier, applies each result's writes + Command.updates to the shared state.
  • run_sends_async — dynamic fan-out. Single-send path runs on the shared state with retry; multi-send path gives each target an isolated state copy (fresh init + restore + input apply) and no retry, preserving the pre-3.0 behavior exactly.

The executor owns execute_node_with_retry_async — the innermost retry loop with exponential backoff + NodeInterrupt pass-through. Retry policies are resolved per node via a lookup callback supplied by GraphEngine at construction; the executor itself is agnostic about where the policy came from.

Thread safety: all fan-out runs on whichever executor co_await asio::this_coro::executor yields — typically GraphEngine's owned thread_pool. Multiple concurrent executions against the same NodeExecutor instance are safe iff the underlying GraphNode subclasses are safe.

3.0 removed the sync run_one/run_parallel/run_sends twins and their process-wide Taskflow executor; sync callers drive the async peers via GraphEngine's thread_pool (see engine.cpp).

Definition in file executor.h.