Skip to content

Async API #26

Description

@fatcerberus

Sphere's internal event loop has long been exposed to the API in a rudimentary capacity. Sphere 1.x has SetUpdateScript() and SetRenderScript(), which only work in the map engine. minisphere brought DispatchScript() to the table, renamed to system.dispatch() in minisphere 4.0, which queues a function to be called on the next engine tick (in practice, on the next FlipScreen()). Async has always been kind of an afterthought in Sphere, because Sphere games have historically been written like C--largely sequential, often with independent "event loops" intermingled with game logic.

If we want to move Sphere forward though, we have to start thinking in terms of async and a central event loop. Platforms like the Web are async-only, and a system like Sphere 1.x would never work in a browser, as has been brought up many times before on the forums.

For my part, I'm implementing an API in minisphere which expands on system.dispatch() to allow more control over the event queue. For example, you'd be able to set up recurring jobs (such as update and render code), and later cancel those if needed.

This issue is to discuss alternatives for a standardized API for such a system. Developers would be able to use such a system to write code which would work both in minisphere as well as a potential "Web Sphere" which implemented the same API, with no changes.

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

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions