Resubscribe before waiting for Task in Emulator

This commit is contained in:
Héctor Ramón Jiménez 2025-08-28 13:10:35 +02:00
parent 720ffa3e0b
commit 2d83da799a
No known key found for this signature in database
GPG key ID: 4C07CEC81AFA161F

View file

@ -101,8 +101,8 @@ impl<P: Program + 'static> Emulator<P> {
pending_tasks: 0, pending_tasks: 0,
}; };
emulator.wait_for(task);
emulator.resubscribe(program); emulator.resubscribe(program);
emulator.wait_for(task);
emulator emulator
} }
@ -110,6 +110,8 @@ impl<P: Program + 'static> Emulator<P> {
pub fn update(&mut self, program: &P, message: P::Message) { pub fn update(&mut self, program: &P, message: P::Message) {
let task = program.update(&mut self.state, message); let task = program.update(&mut self.state, message);
self.resubscribe(program);
match self.mode { match self.mode {
Mode::Zen if self.pending_tasks > 0 => self.wait_for(task), Mode::Zen if self.pending_tasks > 0 => self.wait_for(task),
_ => { _ => {
@ -120,8 +122,6 @@ impl<P: Program + 'static> Emulator<P> {
} }
} }
} }
self.resubscribe(program);
} }
pub fn perform(&mut self, program: &P, action: Action<P>) { pub fn perform(&mut self, program: &P, action: Action<P>) {
@ -290,8 +290,8 @@ impl<P: Program + 'static> Emulator<P> {
program.update(&mut self.state, message) program.update(&mut self.state, message)
})); }));
self.wait_for(task);
self.resubscribe(program); self.resubscribe(program);
self.wait_for(task);
} }
Instruction::Expect(expectation) => match expectation { Instruction::Expect(expectation) => match expectation {
instruction::Expectation::Text(text) => { instruction::Expectation::Text(text) => {