Fix Zen mode finishing early with Task::none()
This commit is contained in:
parent
71ee026444
commit
720ffa3e0b
1 changed files with 7 additions and 5 deletions
|
|
@ -111,7 +111,7 @@ impl<P: Program + 'static> Emulator<P> {
|
||||||
let task = program.update(&mut self.state, message);
|
let task = program.update(&mut self.state, message);
|
||||||
|
|
||||||
match self.mode {
|
match self.mode {
|
||||||
Mode::Zen => self.wait_for(task),
|
Mode::Zen if self.pending_tasks > 0 => self.wait_for(task),
|
||||||
_ => {
|
_ => {
|
||||||
if let Some(stream) = task::into_stream(task) {
|
if let Some(stream) = task::into_stream(task) {
|
||||||
self.runtime.run(
|
self.runtime.run(
|
||||||
|
|
@ -127,10 +127,12 @@ impl<P: Program + 'static> Emulator<P> {
|
||||||
pub fn perform(&mut self, program: &P, action: Action<P>) {
|
pub fn perform(&mut self, program: &P, action: Action<P>) {
|
||||||
match action {
|
match action {
|
||||||
Action::CountDown => {
|
Action::CountDown => {
|
||||||
self.pending_tasks -= 1;
|
if self.pending_tasks > 0 {
|
||||||
|
self.pending_tasks -= 1;
|
||||||
|
|
||||||
if self.pending_tasks == 0 {
|
if self.pending_tasks == 0 {
|
||||||
self.runtime.send(Event::Ready);
|
self.runtime.send(Event::Ready);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Action::Runtime(action) => match action {
|
Action::Runtime(action) => match action {
|
||||||
|
|
@ -349,7 +351,7 @@ impl<P: Program + 'static> Emulator<P> {
|
||||||
self.runtime.send(Event::Ready);
|
self.runtime.send(Event::Ready);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if self.pending_tasks == 0 {
|
||||||
self.runtime.send(Event::Ready);
|
self.runtime.send(Event::Ready);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue