fn check_consistency(&self) -> Result<()> {
        debug!("Checking Task {:?} consistency", self);
        let s = self.get();
        // ID consistency
        if s.id.get_session_id() != s.session.get_id() {
            bail!("ID and Session ID mismatch in {:?}", s);
        }
        // reference symmetries
        if let Some(ref wr) = s.assigned {
            if !wr.get().assigned_tasks.contains(self) {
                bail!("assigned asymmetry in {:?}", s);
            }
        }
        if let Some(ref wr) = s.scheduled {
            let w = wr.get();
            if !w.scheduled_tasks.contains(self) {
                bail!("scheduled asymmetry with {:?} in {:?}", wr, s);
            }
            if w.scheduled_ready_tasks.contains(self) != (s.state == TaskState::Ready) {
                bail!("scheduled_ready_task inconsistency in {:?} at {:?}", s, w);
            }
        }
        if !s.session.get().tasks.contains(self) {
            bail!("session assymetry in {:?}", s);
        }
        // waiting_for and inputs consistency
        for i in s.inputs.iter() {
            let o = i.object.get();
            if o.state == DataObjectState::Removed && s.state != TaskState::Finished {
                bail!("waiting for removed object {:?} in {:?}", o, s);
            }
            if (o.state == DataObjectState::Finished || o.state == DataObjectState::Removed)
                == (s.waiting_for.contains(&i.object))
            {
                bail!(
                    "waiting_for all unfinished inputs invalid woth {:?} in {:?}",
                    o,
                    s
                );
            }
        }
        // outputs consistency
        for or in s.outputs.iter() {
            let o = or.get();
            if o.producer != Some(self.clone()) {
                bail!("output/producer incosistency of {:?} in {:?}", o, s);
            }
            if (o.state == DataObjectState::Finished || o.state == DataObjectState::Removed)
                && s.state != TaskState::Finished
            {
                bail!(
                    "data object {:?} done/removed before the task has finished in {:?}",
                    or,
                    s
                );
            }
        }
        // state constraints
        if !(match s.state {
            TaskState::NotAssigned =>
                s.assigned.is_none() && (!s.waiting_for.is_empty() || s.inputs.is_empty()),
            TaskState::Ready =>
                s.assigned.is_none() && s.waiting_for.is_empty(),
            TaskState::Assigned =>
                s.assigned.is_some() && s.waiting_for.is_empty(),
            TaskState::Running =>
                s.assigned.is_some() && s.waiting_for.is_empty(),
            TaskState::Finished =>
                s.assigned.is_none() && s.waiting_for.is_empty(),
            TaskState::Failed =>
                /* ??? s.assigned.is_none() && */ s.waiting_for.is_empty(),
        }) {
            bail!("state/assigned/waiting_for inconsistency in {:?}", s);
        }
        if s.state == TaskState::Finished && !s.finish_hooks.is_empty() {
            bail!("nonempty finish_hooks in Finished {:?}", s);
        }

        if s.assigned.is_some() && s.scheduled.is_none() && s.state != TaskState::Failed {
            bail!("assigned/scheduled inconsistency in {:?}", s);
        }
        Ok(())
    }
/// Check for state and relationships consistency. Only explores adjacent objects but still
/// may be slow.
Check for state and relationships consistency. Only explores adjacent objects but still
may be slow.
Check for state and relationships consistency . Only explores adjacent objects but still may be slow .
fn check_consistency(&self) -> Result<()> {
        debug!("Checking Task {:?} consistency", self);
        let s = self.get();
        // ID consistency
        if s.id.get_session_id() != s.session.get_id() {
            bail!("ID and Session ID mismatch in {:?}", s);
        }
        // reference symmetries
        if let Some(ref wr) = s.assigned {
            if !wr.get().assigned_tasks.contains(self) {
                bail!("assigned asymmetry in {:?}", s);
            }
        }
        if let Some(ref wr) = s.scheduled {
            let w = wr.get();
            if !w.scheduled_tasks.contains(self) {
                bail!("scheduled asymmetry with {:?} in {:?}", wr, s);
            }
            if w.scheduled_ready_tasks.contains(self) != (s.state == TaskState::Ready) {
                bail!("scheduled_ready_task inconsistency in {:?} at {:?}", s, w);
            }
        }
        if !s.session.get().tasks.contains(self) {
            bail!("session assymetry in {:?}", s);
        }
        // waiting_for and inputs consistency
        for i in s.inputs.iter() {
            let o = i.object.get();
            if o.state == DataObjectState::Removed && s.state != TaskState::Finished {
                bail!("waiting for removed object {:?} in {:?}", o, s);
            }
            if (o.state == DataObjectState::Finished || o.state == DataObjectState::Removed)
                == (s.waiting_for.contains(&i.object))
            {
                bail!(
                    "waiting_for all unfinished inputs invalid woth {:?} in {:?}",
                    o,
                    s
                );
            }
        }
        // outputs consistency
        for or in s.outputs.iter() {
            let o = or.get();
            if o.producer != Some(self.clone()) {
                bail!("output/producer incosistency of {:?} in {:?}", o, s);
            }
            if (o.state == DataObjectState::Finished || o.state == DataObjectState::Removed)
                && s.state != TaskState::Finished
            {
                bail!(
                    "data object {:?} done/removed before the task has finished in {:?}",
                    or,
                    s
                );
            }
        }
        // state constraints
        if !(match s.state {
            TaskState::NotAssigned =>
                s.assigned.is_none() && (!s.waiting_for.is_empty() || s.inputs.is_empty()),
            TaskState::Ready =>
                s.assigned.is_none() && s.waiting_for.is_empty(),
            TaskState::Assigned =>
                s.assigned.is_some() && s.waiting_for.is_empty(),
            TaskState::Running =>
                s.assigned.is_some() && s.waiting_for.is_empty(),
            TaskState::Finished =>
                s.assigned.is_none() && s.waiting_for.is_empty(),
            TaskState::Failed =>
                /* ??? s.assigned.is_none() && */ s.waiting_for.is_empty(),
        }) {
            bail!("state/assigned/waiting_for inconsistency in {:?}", s);
        }
        if s.state == TaskState::Finished && !s.finish_hooks.is_empty() {
            bail!("nonempty finish_hooks in Finished {:?}", s);
        }
        if s.assigned.is_some() && s.scheduled.is_none() && s.state != TaskState::Failed {
            bail!("assigned/scheduled inconsistency in {:?}", s);
        }
        Ok(())
    }
fn check_consistency ( & self ) -> Result < ( ) > { debug ! ( " " self ) ; let s = self . get ( ) ; // ID consistency if s . id . get_session_id ( ) != s . session . get_id ( ) { bail ! ( " " s ) ; } // reference symmetries if let Some ( ref wr ) = s . assigned { if ! wr . get ( ) . assigned_tasks . contains ( self ) { bail ! ( " " s ) ; } } if let Some ( ref wr ) = s . scheduled { let w = wr . get ( ) ; if ! w . scheduled_tasks . contains ( self ) { bail ! ( " " wr s ) ; } if w . scheduled_ready_tasks . contains ( self ) != ( s . state == TaskState :: Ready ) { bail ! ( " " s w ) ; } } if ! s . session . get ( ) . tasks . contains ( self ) { bail ! ( " " s ) ; } // waiting_for and inputs consistency for i in s . inputs . iter ( ) { let o = i . object . get ( ) ; if o . state == DataObjectState :: Removed && s . state != TaskState :: Finished { bail ! ( " " o s ) ; } if ( o . state == DataObjectState :: Finished || o . state == DataObjectState :: Removed ) == ( s . waiting_for . contains ( & i . object ) ) { bail ! ( " " o s ) ; } } // outputs consistency for or in s . outputs . iter ( ) { let o = or . get ( ) ; if o . producer != Some ( self . clone ( ) ) { bail ! ( " " o s ) ; } if ( o . state == DataObjectState :: Finished || o . state == DataObjectState :: Removed ) && s . state != TaskState :: Finished { bail ! ( " " or s ) ; } } // state constraints if ! ( match s . state { TaskState :: NotAssigned => s . assigned . is_none ( ) && ( ! s . waiting_for . is_empty ( ) || s . inputs . is_empty ( ) ) , TaskState :: Ready => s . assigned . is_none ( ) && s . waiting_for . is_empty ( ) , TaskState :: Assigned => s . assigned . is_some ( ) && s . waiting_for . is_empty ( ) , TaskState :: Running => s . assigned . is_some ( ) && s . waiting_for . is_empty ( ) , TaskState :: Finished => s . assigned . is_none ( ) && s . waiting_for . is_empty ( ) , TaskState :: Failed => /* ??? s.assigned.is_none() && */ s . waiting_for . is_empty ( ) , } ) { bail ! ( " " s ) ; } if s . state == TaskState :: Finished && ! s . finish_hooks . is_empty ( ) { bail ! ( " " s ) ; } if s . assigned . is_some ( ) && s . scheduled . is_none ( ) && s . state != TaskState :: Failed { bail ! ( " " s ) ; } Ok ( ( ) ) }
Check for state and relationships consistency.
Check for state and relationships consistency .
&self
&self