I am trying to use async functions from a dynamically linked library with the help of stabby crate. Stabby provides the stable abi function interface and a stable future. In my #tokio::main I can await for my async library function. In that function I can use await as well, but not things like tokio::spawn or tokio::sleep. In the latter case I get an "there is no reactor running" panic in the library function. Does anyone have any experience with such a setup?
probably different versions of tokio is used. check:
$ cargo tree | grep tokio
Your dynamic library needs to setup a separate tokio runtime: tokio::runtime - Rust Stabby can't share the tokio runtime across the ABI boundary as tokio doesn't have a stable ABI for the runtime.
Thank you, that's what I feared. Do you maybe know any other solution around except for stabby, that implements async across the ABI boundary while keeping the runtime? Or another question:
in my library, I start a new runtime, share it within the library, and in each function call a block_on on this runtime. This leads to a blocking when I wait for two library async functions in, for example, a select! in the app. Starting a new runtime each time I call a library function seem to be not very efficient either. What one could do here, any suggestions?
I don't think tokio is modular enough to allow intercepting runtime calls from within the shared library and forward them over a stabby abi to the host runtime. What kind of work are you trying to do in the shared library and would it be possible to have a minimal async runtime that passes all requests over the ABI boundary as replacement for tokio?
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.