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

Async Turtles #17

Open
sunjay opened this issue Nov 10, 2017 · 1 comment
Open

Async Turtles #17

sunjay opened this issue Nov 10, 2017 · 1 comment

Comments

@sunjay
Copy link
Owner

sunjay commented Nov 10, 2017

We should have an off-by-default feature called "async" which makes all of the turtle methods return Future<...> types instead of nothing. This would require a complete restructuring and is probably a great thing to do with #16 since that requires significant refactoring too. When the feature is off, the methods would call the async code and then run wait() at the end instead of returning the future. Though each method returns immediately, the animations are queued up within each turtle and played sequentially. The futures return when their respective animations complete. Getters for the various properties return the current value immediately and do not represent any specific state after a given animation.

Animations can still be controlled and coordinated by chaining and composing different futures, perhaps with async/await syntax.

This would enable a huge range of really interesting and complex use cases--great for advanced lessons! That being said, it's important that the library in its default state remains extremely simple and usable.

impl Turtle {
    fn into_async(self) -> AsyncTurtle {
        ...
    }
}

impl AsyncTurtle {
    fn into_sync(self) -> Turtle {
        ...
    }
}
@sunjay
Copy link
Owner Author

sunjay commented May 25, 2020

A large portion of the work for this issue was completed in #173. There is now an AsyncTurtle struct and an AsyncDrawing struct for interacting with the crate asynchronously. We're still working out the API and there are no docs yet, so neither of those types has been made public.

If you'd like to try them out, you can do so by creating a local copy of the crate and manually marking those structs pub yourself. This is still largely experimental and there are many bugs/performance issues that need to be worked out. Feel free to experiment and report back what you find!

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

No branches or pull requests

1 participant