Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tokio::Runtime::enter #175

Merged
merged 1 commit into from
Oct 26, 2023

Conversation

TennyZhuang
Copy link
Contributor

@TennyZhuang TennyZhuang commented Oct 20, 2023

Signed-off-by: TennyZhuang <zty0826@gmail.com>
@TennyZhuang
Copy link
Contributor Author

It seems that we can madsim::spawn without any initialization operations? So I guess no-op here is OK.

@wangrunji0408 wangrunji0408 self-requested a review October 20, 2023 17:03
Copy link
Member

@wangrunji0408 wangrunji0408 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Could you also help bump version to v0.2.24 and update the changelog? thx

@wangrunji0408
Copy link
Member

wangrunji0408 commented Oct 20, 2023

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?

@TennyZhuang
Copy link
Contributor Author

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?

It seems that the bug exists even without the PR?

@wangrunji0408
Copy link
Member

Yes. Let's fix it later.

@TennyZhuang
Copy link
Contributor Author

Yes. Let's fix it later.

Can you merge the PR and release a new version?

@wangrunji0408 wangrunji0408 merged commit 2b34c9d into madsim-rs:main Oct 26, 2023
12 checks passed
@wangrunji0408
Copy link
Member

Sorry. forgot this 🤡

@wangrunji0408
Copy link
Member

published as v0.2.24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants