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

Custom async for cleaner code #16

Open
nic-hartley opened this issue Jan 16, 2023 · 0 comments
Open

Custom async for cleaner code #16

nic-hartley opened this issue Jan 16, 2023 · 0 comments
Labels
k: new system a whole new system to integrate into the engine p: tuig tuig crate

Comments

@nic-hartley
Copy link
Owner

Currently everything needs to be manually written as a state machine, so we can have proper concurrency. But there's already tech in Rust for being able to write relatively normal code, while the compiler turns it into a state machine: async.

I don't want to use normal async, i.e. tokio or async-std, for two reasons:

  • The executors are design to work for system IO, whereas I'm mostly gonna be waiting for events and (in-game) time passing, so there's a lot of unnecessary features.
  • That also makes them very no_std/WASM-unfriendly, whereas -- since I don't need them for IO -- a custom async executor could be much nicer about it.

The downside, of course, is that it's a lot of work, but I think it'd fit nicely into the engine.

The biggest issue I can foresee is the risk of intermixing asyncs. I have no idea how big the risk will be of someone trying to pass Tokio executors to me, or my futures to Tokio -- and that's a problem! It could be a very big problem! That said, I assume it's solvable, from how there's more than one async executor and people don't seem to have issues with accidentally intermixing them.

@nic-hartley nic-hartley added p: tuig tuig crate k: new system a whole new system to integrate into the engine labels Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
k: new system a whole new system to integrate into the engine p: tuig tuig crate
Projects
None yet
Development

No branches or pull requests

1 participant