Crate allo_isolate
source ·Expand description
Allo Isolate Run Multithreaded Rust along with Dart VM (in isolate).
Since you can’t call into dart from other threads other than the main
thread, that holds our rust code from beaing multithreaded, the way that can be done is using Dart Isolate
by creating an isolate, send its NativePort
to Rust side, then rust is freely could run and send the result back on that port.
Interacting with Dart VM directly isn’t that easy, that is why we created
that library, it provides IntoDart
trait to convert between Rust data
types and Dart Types, and by default it is implemented for all common rust
types.
§Example
See flutterust
and how we used it in the scrap
package to create a webscrapper using Rust and Flutter.
§Cargo Features
catch-unwind
: Unwind the Rust stack after a panic, instead of stopping the thread.zero-copy
: Zero copy typed data by default without explicitZeroCopyBuffer
. For example,Vec<u8>
in Rust will be moved to the Dart side asUInt8List
without any copy operation, which can have performance benefits.
Re-exports§
pub use ffi::ZeroCopyBuffer;
Modules§
Structs§
- Simple wrapper around the Dart Isolate Port, nothing else.
Traits§
- A trait to convert between Rust types and Dart Types that could then be sent to the isolate
Functions§
- Stores the function pointer of
Dart_PostCObject
, this only should be called once at the start up of the Dart/Flutter Application. it is exported and marked as#[no_mangle]
.