diff --git a/src/runtime2/component/component_pdl.rs b/src/runtime2/component/component_pdl.rs index 236cff963e1047d61a0c3f607543776650f6b2b6..1ff5db7821f8ffaa23ef05b0672f5d5a7f0afb4e 100644 --- a/src/runtime2/component/component_pdl.rs +++ b/src/runtime2/component/component_pdl.rs @@ -272,21 +272,13 @@ impl Component for CompPDL { CompMode::SyncEnd | CompMode::BlockedGet | CompMode::BlockedPut | CompMode::BlockedSelect => { return Ok(CompScheduling::Sleep); } - CompMode::StartExit => { - self.handle_component_exit(sched_ctx, comp_ctx); - return Ok(CompScheduling::Immediate); - }, - CompMode::BusyExit => { - if self.control.has_acks_remaining() { - return Ok(CompScheduling::Sleep); - } else { - self.exec_state.mode = CompMode::Exit; - return Ok(CompScheduling::Exit); - } - }, - CompMode::Exit => { - return Ok(CompScheduling::Exit); - } + CompMode::StartExit => return Ok(component::default_handle_start_exit( + &mut self.exec_state, &mut self.control, sched_ctx, comp_ctx + )), + CompMode::BusyExit => return Ok(component::default_handle_busy_exit( + &mut self.exec_state, &self.control, sched_ctx + )), + CompMode::Exit => return Ok(component::default_handle_exit(&self.exec_state)), } let run_result = self.execute_prompt(&sched_ctx)?; @@ -471,22 +463,20 @@ impl CompPDL { /// appropriate next steps. fn handle_sync_decision(&mut self, sched_ctx: &SchedulerCtx, _comp_ctx: &mut CompCtx, decision: SyncRoundDecision) { sched_ctx.log(&format!("Handling sync decision: {:?} (in mode {:?})", decision, self.mode)); - let is_success = match decision { + match decision { SyncRoundDecision::None => { // No decision yet return; }, - SyncRoundDecision::Solution => true, - SyncRoundDecision::Failure => false, - }; - - // If here then we've reached a decision - debug_assert_eq!(self.exec_state.mode, CompMode::SyncEnd); - if is_success { - self.exec_state.mode = CompMode::NonSync; - self.consensus.notify_sync_decision(decision); - } else { - self.exec_state.mode = CompMode::StartExit; + SyncRoundDecision::Solution => { + debug_assert_eq!(self.exec_state.mode, CompMode::SyncEnd); + self.exec_state.mode = CompMode::NonSync; + self.consensus.notify_sync_decision(decision); + }, + SyncRoundDecision::Failure => { + debug_assert_eq!(self.exec_state.mode, CompMode::SyncEnd); + self.exec_state.mode = CompMode::StartExit; + }, } }