{"action":"opened","issue":{"url":"https://api.github.com/repos/sphere-group/pegasus/issues/26","repository_url":"https://api.github.com/repos/sphere-group/pegasus","labels_url":"https://api.github.com/repos/sphere-group/pegasus/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/sphere-group/pegasus/issues/26/comments","events_url":"https://api.github.com/repos/sphere-group/pegasus/issues/26/events","html_url":"https://github.com/sphere-group/pegasus/issues/26","id":186213429,"number":26,"title":"Async API","user":{"login":"fatcerberus","id":4097841,"avatar_url":"https://avatars.githubusercontent.com/u/4097841?v=3","gravatar_id":"","url":"https://api.github.com/users/fatcerberus","html_url":"https://github.com/fatcerberus","followers_url":"https://api.github.com/users/fatcerberus/followers","following_url":"https://api.github.com/users/fatcerberus/following{/other_user}","gists_url":"https://api.github.com/users/fatcerberus/gists{/gist_id}","starred_url":"https://api.github.com/users/fatcerberus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fatcerberus/subscriptions","organizations_url":"https://api.github.com/users/fatcerberus/orgs","repos_url":"https://api.github.com/users/fatcerberus/repos","events_url":"https://api.github.com/users/fatcerberus/events{/privacy}","received_events_url":"https://api.github.com/users/fatcerberus/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-31T06:16:10Z","updated_at":"2016-10-31T06:16:10Z","closed_at":null,"body":"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.\r\n\r\nIf 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.\r\n\r\nFor 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.\r\n\r\nThis 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."}}
{"actor":{"display_login":"fatcerberus"}}