prokio
prokio copied to clipboard
Provide example of using this crate
I couldn't find any information on actually using this crate. An example script file or at least a snippet of using it somewhere would help a ton.
My use case (not sure if it fits the scope of the crate):
I'm trying to use it as a replacement for tokio::runtime::Runtime that will also work on the browser, but after constructing it and calling .spawn_pinned(..) on it, I'm unsure what to do with the runtime. "Normally" I would call .block_on(..) on this runtime in the main function, but that method seems to be missing..
I agree this crate should add more documentation / examples around how it should be used.
In general, tasks meant to be run with the prokio runtime should always be spawned to a worker thread and outputs / results should be obtained with channels. Prokio should not be used in the main thread as browser is always non-blocking and hence it does not provide a #[prokio::main] macro.
You can check out Yew's server renderer about how to use it: https://github.com/yewstack/yew/blob/master/packages/yew/src/server_renderer.rs#L203
Good to know, thanks for the information!