pub struct ExecutionContext<'a> {
pub workspace_root: &'a Path,
pub registry: &'a SymbolRegistry,
pub graph: &'a CodeGraphV2,
pub files: ImHashMap<WorkspaceFilePath, Arc<PureFile>>,
}Expand description
Context for parallel Mutation execution.
Created by AnalysisContext::fork(). Shares Registry and Graph as
read-only references, with Files using O(log n) structural sharing.
§Design
AnalysisContext (owner)
├── workspace_root: Arc<Path> │
├── registry: SymbolRegistry ──┤
├── graph: CodeGraphV2 │ shared (read-only)
└── files: im::HashMap<...> │
│
ExecutionContext<'a> │
├── workspace_root: &'a Path ←┘
├── registry: &'a SymbolRegistry ←┘
├── graph: &'a CodeGraphV2 ←┘
└── files: im::HashMap<...> (O(log n) clone, copy-on-write)§Performance
- Clone: O(log n) via
im::HashMapstructural sharing - Modification: Copy-on-write via
Arc::make_mut
§Collecting Changes
Mutations return RegistryUpdate deltas instead of modifying Registry directly.
These are collected and applied to AnalysisContext at Tick end.
See docs/parallel-execution-design.md for the full design.
Fields§
§workspace_root: &'a PathRead-only reference to workspace root.
registry: &'a SymbolRegistryRead-only reference to SymbolRegistry.
Mutations should collect changes as RegistryUpdate instead of
modifying directly.
graph: &'a CodeGraphV2Read-only reference to CodeGraphV2.
files: ImHashMap<WorkspaceFilePath, Arc<PureFile>>Files with O(log n) clone via structural sharing.
Uses im::HashMap<WorkspaceFilePath, Arc<PureFile>> for:
- O(log n) clone (structural sharing)
- Copy-on-write modification via
Arc::make_mut
Implementations§
Source§impl<'a> ExecutionContext<'a>
impl<'a> ExecutionContext<'a>
Sourcepub fn file(&self, path: &WorkspaceFilePath) -> Option<&PureFile>
pub fn file(&self, path: &WorkspaceFilePath) -> Option<&PureFile>
Get a file by path.
Sourcepub fn file_mut(&mut self, path: &WorkspaceFilePath) -> Option<&mut PureFile>
pub fn file_mut(&mut self, path: &WorkspaceFilePath) -> Option<&mut PureFile>
Get a mutable file by path (copy-on-write).
Uses Arc::make_mut for copy-on-write semantics:
- If Arc is uniquely owned, returns mutable reference directly
- If Arc is shared, clones the PureFile first
Sourcepub fn has_file(&self, path: &WorkspaceFilePath) -> bool
pub fn has_file(&self, path: &WorkspaceFilePath) -> bool
Check if a file exists.
Sourcepub fn file_count(&self) -> usize
pub fn file_count(&self) -> usize
Get the number of files.
Auto Trait Implementations§
impl<'a> Freeze for ExecutionContext<'a>
impl<'a> RefUnwindSafe for ExecutionContext<'a>
impl<'a> Send for ExecutionContext<'a>
impl<'a> Sync for ExecutionContext<'a>
impl<'a> Unpin for ExecutionContext<'a>
impl<'a> UnsafeUnpin for ExecutionContext<'a>
impl<'a> UnwindSafe for ExecutionContext<'a>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more