pub struct WaitForGraph { /* private fields */ }Expand description
Wait-For Graph for deadlock detection
Maintains a graph where:
- Nodes represent robots
- Edges represent “waits-for” relationships
A cycle in this graph indicates a deadlock.
Implementations§
Source§impl WaitForGraph
impl WaitForGraph
Sourcepub fn add_wait(&mut self, robot: RobotId, waiting_for: WaitingFor)
pub fn add_wait(&mut self, robot: RobotId, waiting_for: WaitingFor)
Record that a robot is waiting for a resource
Sourcepub fn remove_wait(&mut self, robot: RobotId)
pub fn remove_wait(&mut self, robot: RobotId)
Remove a robot’s wait (e.g., when it acquires the resource)
Sourcepub fn is_waiting(&self, robot: RobotId) -> bool
pub fn is_waiting(&self, robot: RobotId) -> bool
Check if a robot is currently waiting
Sourcepub fn get_wait(&self, robot: RobotId) -> Option<&WaitingFor>
pub fn get_wait(&self, robot: RobotId) -> Option<&WaitingFor>
Get what a robot is waiting for, if anything
Sourcepub fn waiting_count(&self) -> usize
pub fn waiting_count(&self) -> usize
Get the number of robots currently waiting
Sourcepub fn detect_cycle(&self) -> Option<Vec<RobotId>>
pub fn detect_cycle(&self) -> Option<Vec<RobotId>>
Detect if there’s a cycle (deadlock) in the wait-for graph
Returns Some(cycle) with the robot IDs forming the cycle, or None if no deadlock exists.
Uses DFS-based cycle detection.
Sourcepub fn detect_all_cycles(&self) -> Vec<Vec<RobotId>>
pub fn detect_all_cycles(&self) -> Vec<Vec<RobotId>>
Detect all cycles in the graph (for debugging/analysis)
Trait Implementations§
Source§impl Clone for WaitForGraph
impl Clone for WaitForGraph
Source§fn clone(&self) -> WaitForGraph
fn clone(&self) -> WaitForGraph
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for WaitForGraph
impl Debug for WaitForGraph
Source§impl Default for WaitForGraph
impl Default for WaitForGraph
Source§fn default() -> WaitForGraph
fn default() -> WaitForGraph
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for WaitForGraph
impl RefUnwindSafe for WaitForGraph
impl Send for WaitForGraph
impl Sync for WaitForGraph
impl Unpin for WaitForGraph
impl UnwindSafe for WaitForGraph
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Returns whether the given value has been niched. Read more
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
Writes data to
out indicating that a T is niched.