Closed TennyZhuang closed 8 months ago
It seems that we can madsim::spawn
without any initialization operations? So I guess no-op here is OK.
Wait a moment. I found a problem. When a Runtime
is dropped, all tasks spawned in it should also be cancelled. Therefore, madsim::spawn
should find the current runtime first and store the task in it. However, this is not the case now, which means that if we create a runtime R, spawn a task A by R.spawn()
, and then spawn a new task B in A using madsim::spawn
, B will not be dropped along with runtime R. This is a bug that should definitely be fixed. Would you prefer to fix it in this PR or enable this API first and then fix the problem later?
Wait a moment. I found a problem. When a
Runtime
is dropped, all tasks spawned in it should also be cancelled. Therefore,madsim::spawn
should find the current runtime first and store the task in it. However, this is not the case now, which means that if we create a runtime R, spawn a task A byR.spawn()
, and then spawn a new task B in A usingmadsim::spawn
, B will not be dropped along with runtime R. This is a bug that should definitely be fixed. Would you prefer to fix it in this PR or enable this API first and then fix the problem later?
It seems that the bug exists even without the PR?
Yes. Let's fix it later.
Yes. Let's fix it later.
Can you merge the PR and release a new version?
Sorry. forgot this 🤡
published as v0.2.24
https://docs.rs/tokio/latest/tokio/runtime/struct.Runtime.html#method.enter