NeoGraph 0.16.0
A C++20 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 <chrono>
#include <exception>
#include <functional>
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#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...
 

Functions

NEOGRAPH_API bool neograph::graph::wait_for_node_attempts (std::chrono::milliseconds timeout=std::chrono::milliseconds::max())
 Wait until no node attempt dispatched off its run's orchestrator is running anywhere in this process (#364, #367, #368).
 

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. Every Send, one or many, runs on an isolated state copy (fresh init + restore + input apply) with retry, so a payload is visible only to its own Send (#389); several Sends run as a parallel group.

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 the former process-wide executor. Sync callers drive the Asio coroutine peers inline by default or through GraphEngine's opt-in thread_pool (see graph_engine.cpp).

Definition in file executor.h.

Function Documentation

◆ wait_for_node_attempts()

NEOGRAPH_API bool neograph::graph::wait_for_node_attempts ( std::chrono::milliseconds  timeout = std::chrono::milliseconds::max())

Wait until no node attempt dispatched off its run's orchestrator is running anywhere in this process (#364, #367, #368).

An attempt that ignored its cancellation past its stop deadline outlives the run that timed it out (the run failed with NG.EffectUncertain). A host that is about to exit, or to tear down what such a node uses, can wait for it here. The Python binding does so at interpreter exit.

Parameters
timeoutHow long to wait; milliseconds::max() waits without a limit.
Returns
True when no dispatched attempt is running.

References neograph::graph::wait_for_node_attempts().

Referenced by neograph::graph::wait_for_node_attempts().