|
|
|
@ -297,19 +297,22 @@ impl Handler<RunProgram> for ProgramRunnerActor {
@@ -297,19 +297,22 @@ impl Handler<RunProgram> for ProgramRunnerActor {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[derive(Message)] |
|
|
|
|
#[rtype(result = "()")] |
|
|
|
|
#[rtype(result = "Option<ProgramRef>")] |
|
|
|
|
struct CancelProgram(ProgramId); |
|
|
|
|
|
|
|
|
|
impl Handler<CancelProgram> for ProgramRunnerActor { |
|
|
|
|
type Result = (); |
|
|
|
|
type Result = Option<ProgramRef>; |
|
|
|
|
fn handle(&mut self, msg: CancelProgram, ctx: &mut Self::Context) -> Self::Result { |
|
|
|
|
let CancelProgram(program_id) = msg; |
|
|
|
|
let mut cancelled = None; |
|
|
|
|
for run in self.run_queue.iter_mut() { |
|
|
|
|
if run.program.id == program_id { |
|
|
|
|
run.state = RunState::Cancelled; |
|
|
|
|
cancelled = Some(run.program.clone()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
ctx.notify(Process); |
|
|
|
|
cancelled |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -448,7 +451,7 @@ impl ProgramRunner {
@@ -448,7 +451,7 @@ impl ProgramRunner {
|
|
|
|
|
.map_err(ProgramRunnerError::from) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub async fn cancel_program(&mut self, program_id: ProgramId) -> Result<()> { |
|
|
|
|
pub async fn cancel_program(&mut self, program_id: ProgramId) -> Result<Option<ProgramRef>> { |
|
|
|
|
self.addr |
|
|
|
|
.send(CancelProgram(program_id)) |
|
|
|
|
.await |
|
|
|
|