-
Notifications
You must be signed in to change notification settings - Fork 0
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
Use a type-aligned SplitSeq to store the continuation frames #3
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…eq.resumeWith and vice versa
Change sentinel WrapperCont values to failures for type safety
…face from SplitSeq
Introduce *once and *withFinal methods for capturing continuations Use UnconfinedTestDispatcher and SingleShotSegment for long tests Inline WrapperContContext Inline CanSuspend in FibersTest Introduce fast aborting that doesn't use exceptions (was causing problems on JS) Add more Skynet variations Introduce cleaner deleteReader method for deleteBinding
…l handle, and reduce its usages
… that's more effekt-y
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Every item of such a sequence is either a mark (Reader/Prompt) or real stack frames (which are now only copied when absolutely necessary).
Technically, there's a one-shot core that can be extracted here that uses no reflection, but I'll leave that to the future.
This is based on java-effekt's implementation, but with added types, and explicit tail-rec-ness. I also added kotlin-specific optimizations here to "trampoline" resumptions into frames. That code should ideally be extracted into a smaller component.
Also, this implementation takes O(1) time for
pushPrompt
, O(k) time fortakeSubCont
, and O(k) time forpushSubCont
, where k is the amount of marks from here to the relevant Prompt (so it's the amount of marks separating us from the Prompt intakeSubCont
, and the amount of marks in the stored SubCont inpushSubCont
). I doubt thattakeSubCont
can be made faster (unless we use a hashmap or something), butpushSubCont
can definitely be made constant-time, although that'll make the code more complex (the likely way to do so is using the "Reflection without Remorse" technique of using a sequence that'll have amortized constant-time access to the "current" continuation frame, but IIRC this has horrible constants involved).This also implements delayed copying for Reader's values.
This doesn't currently support a dynamic-wind style operation, also it hasn't needed to exist just yet.