After quite some time debugging my FFI application, I found out that internal registration calls that looked for the current tokio Handle would panic. Indeed, the FFI function which gets called from Java does not enter the tokio runtime, yet, it uses features which require registration. Hence, my program crashes.
The latest Tokio 0.3 on github does not appear to have a cloneable
Handle interface. This would be convenient to have, as I'd be able to clone the handle and save it statically for the FFI to use later (then
enter the runtime). One solution is to have a
Receiver on an async task taking FFI commands, but, this is undesirable as I want the function call to return data back to Java immediately. What should be done?