Skip to content

Async Turtles #17

Description

@sunjay

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 {
        ...
    }
}

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions