Struct allo_isolate::Isolate
source · [−]pub struct Isolate { /* private fields */ }
Expand description
Simple wrapper around the Dart Isolate Port, nothing else.
Implementations
sourceimpl Isolate
impl Isolate
sourcepub const fn new(port: i64) -> Self
pub const fn new(port: i64) -> Self
Create a new Isolate
with a port obtained from Dart VM side.
Example
this a non realistic example lol :D
let isolate = Isolate::new(42);
sourcepub fn post(&self, msg: impl IntoDart) -> bool
pub fn post(&self, msg: impl IntoDart) -> bool
Post an object to the Isolate
over the port
Object must implement IntoDart
.
returns true
if the message posted successfully, otherwise false
Safety
This assumes that you called store_dart_post_cobject
and we have
access to the Dart_PostCObject
function pointer also, we do check
if it is not null.
Example
let isolate = Isolate::new(42);
isolate.post("Hello Dart !");
sourcepub async fn task<T, R>(self, t: T) -> bool where
T: Future<Output = R> + Send + 'static,
R: Send + IntoDart + 'static,
pub async fn task<T, R>(self, t: T) -> bool where
T: Future<Output = R> + Send + 'static,
R: Send + IntoDart + 'static,
Consumes Self
, Runs the task, await for the result and then post it
to the Isolate
over the port
Result must implement IntoDart
.
returns true
if the message posted successfully, otherwise false
Safety
This assumes that you called store_dart_post_cobject
and we have
access to the Dart_PostCObject
function pointer also, we do check
if it is not null.
Example
use async_std::task;
let isolate = Isolate::new(42);
task::spawn(isolate.task(async { 1 + 2 }));
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Isolate
impl Send for Isolate
impl Sync for Isolate
impl Unpin for Isolate
impl UnwindSafe for Isolate
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more