-
Notifications
You must be signed in to change notification settings - Fork 28
Add API for explicitly starting/stopping runtimes and spawning futures on a specific runtime #42
Comments
I wonder if we follow #43, we could in addition also add a builder to set varying options. Not quite sure what that API would look like, but I think it might allow us to tick the right boxes (: |
#43 is mostly about being able to call async functions in a blocking fashion, or not? While that might internally spawn a runtime (or maybe just run things on an existing runtime and block on a condition variable?), this seems not that closely related to being able to spawn and shut down your own runtimes in one way or another. For that you probably don't necessarily want to block directly on a future but have some more API for a) creating a runtime (with whatever settings), b) actually starting it (which for a single threaded runtime would block the current thread, otherwise probably not?), and c) for shutting it down (and being able to wait for it to be shut down). I realize that you model a) and b) together with such a But maybe you're thinking of a nice API for doing all that together at once that I don't see right now, so maybe it's actually fine :) |
@sdroege thanks for clarifying! -- I think I might have intially missed some of the constraints you laid out, so this has been very helpful! |
Currently runtimes in
runtime
are fully implicit and run in the background without any control over their lifetime, what futures get run on them or what (and how many threads) they use.It would be useful to have API for all of the above. There are a couple of use-cases I can think of, some of which I'm doing with tokio currently in one way or another.
GMainContext
/GMainLoop
). There's the global default one, which is used also for the GTK+ toolkit to do all the UI things, but if you have other parts of your application doing async operations it often makes sense to create a separate one that runs on another thread (they're always single-threaded) to not interfere with the UI event loop in any way.I realize that this goes a bit against the goal of making everything as simple as possible to use, but maybe such an API for starting/stopping/configuring runtimes could be made available in addition to the simple, do-it-all-implicitly API.
The text was updated successfully, but these errors were encountered: