I am developing library in rust that would be used in iOS app. Library runs tokio event loop in one thread and iOS app will call functions written in rust from different threads.
Basically it works but rarely crashes.
FFI breaks safety. All FFI calls, callbacks are unsafe by default
https://doc.rust-lang.org/nomicon/ffi.html#asynchronous-callbacks - that article tells I must use channel or mutex.
So I use channel but I lack docs/example/knowledge how to make that right.
Could you advice some example or project that does rust library in correct canonical way and uses channels like advised in article?
e.g. I am not sure std::sync::mpsc::SyncSender could be put in static variable and be used by random thread calling rust via FFI.
Also I am not sure if futures::task::Task or task.notify() could be shared same way.