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

achieve a similar effect to stacker::maybe_grow #35

Closed
wants to merge 2 commits into from

Conversation

loongs-zhang
Copy link
Contributor

@loongs-zhang loongs-zhang commented Sep 21, 2024

when #33 get merged, all CI of this PR should pass.

src/coroutine.rs Outdated Show resolved Hide resolved
@Amanieu
Copy link
Owner

Amanieu commented Oct 4, 2024

After thinking about this for a while, I think that this functionality doesn't belong in corosensei itself. Instead it should be provided in a separate crate, as a wrapper around a Coroutine. While corosensei can provide the base functionality for stack switching, the logic for querying the remaining amount of stack requires std (corosensei is #![no_std]). You can already query the limit of a stack using the limit() trait method.

@Amanieu Amanieu closed this Oct 4, 2024
@Amanieu
Copy link
Owner

Amanieu commented Oct 5, 2024

In fact you should prefer using on_stack instead of Coroutine if you don't need support for yielding. It will be much faster.

@loongs-zhang
Copy link
Contributor Author

After thinking about this for a while, I think that this functionality doesn't belong in corosensei itself. Instead it should be provided in a separate crate, as a wrapper around a Coroutine. While corosensei can provide the base functionality for stack switching, the logic for querying the remaining amount of stack requires std (corosensei is #![no_std]). You can already query the limit of a stack using the limit() trait method.

So does corosensei still need remaining_stack?

@loongs-zhang
Copy link
Contributor Author

In fact you should prefer using on_stack instead of Coroutine if you don't need support for yielding. It will be much faster.

Haha, I need yielding.

@Amanieu
Copy link
Owner

Amanieu commented Oct 7, 2024

No. In fact remaining_stack can return incorrect results with your implementation since the stack pointer may not necessarily be on the coroutine stack: it could have switched to another stack temporarily and then yielded.

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