pub struct Executor { /* private fields */ }Expand description
Executor for running graph nodes in topological order.
§Thread Safety
The Executor is NOT thread-safe for concurrent executions on the same instance.
While execute() is async and takes &self (shared reference), the underlying
implementation assumes single-threaded access patterns:
self.nodesis a regularHashMapwithout synchronization- Multiple concurrent calls to
execute()would have data races when accessing nodes
§Safe Usage Patterns
- Single execution at a time: Only call
execute()once at a time per executor instance - Clone for parallelism: Create separate executor instances for parallel graph executions
- Sequential async: Use
.awaitto ensure executions don’t overlap
§Future Work
For true concurrent execution support, wrap nodes in Arc<RwLock<HashMap>> or similar.
Implementations§
Source§impl Executor
impl Executor
pub fn new() -> Self
Sourcepub fn with_cache(cache: CacheManager) -> Self
pub fn with_cache(cache: CacheManager) -> Self
Create a new executor with caching enabled
Sourcepub fn set_cache(&mut self, cache: CacheManager)
pub fn set_cache(&mut self, cache: CacheManager)
Enable caching for this executor
Sourcepub fn cache(&self) -> Option<&CacheManager>
pub fn cache(&self) -> Option<&CacheManager>
Get the cache manager (if enabled)
Sourcepub fn metrics(&self) -> &ExecutionMetrics
pub fn metrics(&self) -> &ExecutionMetrics
Get execution metrics from last run
Sourcepub fn reset_metrics(&mut self)
pub fn reset_metrics(&mut self)
Reset execution metrics
Sourcepub fn from_graph_def(def: &GraphDef) -> Result<Self>
pub fn from_graph_def(def: &GraphDef) -> Result<Self>
Build executor from graph definition
Sourcepub fn register_node(&mut self, node: Box<dyn Node>)
pub fn register_node(&mut self, node: Box<dyn Node>)
Register a node with the executor
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Executor
impl !RefUnwindSafe for Executor
impl Send for Executor
impl Sync for Executor
impl Unpin for Executor
impl !UnwindSafe for Executor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more