Skip to content
This repository was archived by the owner on Oct 3, 2025. It is now read-only.

Commit 9ff3d6d

Browse files
committed
fix: support for multiple resumes on single suspendedFucn now works
1 parent 30292a6 commit 9ff3d6d

File tree

1 file changed

+5
-1
lines changed
  • crates/tinywasm/src/interpreter

1 file changed

+5
-1
lines changed

crates/tinywasm/src/interpreter/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ impl<'a> coro::CoroState<stack::Stack, FuncContext<'a>> for SuspendedRuntime {
5050
ctx: FuncContext<'a>,
5151
arg: ResumeArgument,
5252
) -> Result<coro::CoroStateResumeResult<stack::Stack>> {
53+
// should be put back into self.body unless we're finished
5354
let (body, mut stack) = if let Some(body_) = self.body.take() {
5455
body_
5556
} else {
@@ -66,7 +67,10 @@ impl<'a> coro::CoroState<stack::Stack, FuncContext<'a>> for SuspendedRuntime {
6667
};
6768
match resumed {
6869
executor::ExecOutcome::Return(()) => Ok(coro::CoroStateResumeResult::Return(stack)),
69-
executor::ExecOutcome::Suspended(suspend) => Ok(coro::CoroStateResumeResult::Suspended(suspend)),
70+
executor::ExecOutcome::Suspended(suspend) => {
71+
self.body = Some((Self::unmake_exec(exec), stack));
72+
Ok(coro::CoroStateResumeResult::Suspended(suspend))
73+
}
7074
}
7175
}
7276
}

0 commit comments

Comments
 (0)