Skip to main content

aft_base/executor/
context.rs

1//! Runtime operations the scheduler needs from its actor context.
2
3use std::path::{Path, PathBuf};
4use std::sync::Arc;
5
6use super::{RootMaintenanceExecutor, SubcLifecycleAdmission};
7
8/// Process census callbacks used when an executor adds or removes a root.
9pub trait ExecutorApp<C: ExecutorContext>: Send + Sync + 'static {
10    fn register_memory_context(&self, root: PathBuf, ctx: &Arc<C>);
11    fn unregister_memory_context(&self, root: &Path, ctx: &Arc<C>);
12    fn actor_root_registered(&self);
13    fn actor_root_unregistered(&self);
14}
15
16/// The context operations already performed at scheduler admission and execution.
17/// Associated types let each runtime define the application handle and config-pin guard it uses.
18pub trait ExecutorContext: Send + Sync + Sized + 'static {
19    type App: ExecutorApp<Self>;
20    type ConfigPin;
21
22    fn bind_status_context(self: &Arc<Self>);
23    fn install_callgraph_executor(&self, executor: RootMaintenanceExecutor);
24    fn app(&self) -> Arc<Self::App>;
25    fn storage_dir(&self) -> PathBuf;
26    fn teardown_deleted_root(&self);
27    fn subc_unbound_quiesced(&self) -> bool;
28    fn subc_lifecycle_admission(&self) -> SubcLifecycleAdmission;
29    fn run_if_subc_bound_generation<R>(
30        &self,
31        generation: u64,
32        run: impl FnOnce() -> R,
33    ) -> Option<R>;
34    fn configure_generation(&self) -> u64;
35    fn begin_configure_ack_phase(&self, phase: &'static str);
36    fn configure_ack_phase_snapshot(&self) -> String;
37    fn configure_tail_stage_snapshot(&self) -> Option<String>;
38    fn pin_config(&self) -> Self::ConfigPin;
39}