Trait jlrs::extensions::multitask::async_task::AsyncTask [−][src]
pub trait AsyncTask: Send + Sync + 'static { type T: 'static + Send + Sync; type R: ReturnChannel<T = Self::T>; fn run<'base, 'life0, 'life1, 'async_trait>(
&'life0 mut self,
global: Global<'base>,
frame: &'life1 mut AsyncGcFrame<'base>
) -> Pin<Box<dyn Future<Output = JlrsResult<Self::T>> + 'async_trait>>
where
'base: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait; fn return_channel(&self) -> Option<&Self::R> { ... } }
Expand description
The AsyncTask
trait is used to create tasks that the async runtime can execute.
Implementations of this trait take the place of the closures used with the sync runtime.
Associated Types
The type of the result of this task. Must be the same across all implementations.
type R: ReturnChannel<T = Self::T>
type R: ReturnChannel<T = Self::T>
The type of the sender that is used to send the result of this task back to the original caller. Must be the same across all implementations.
Required methods
fn run<'base, 'life0, 'life1, 'async_trait>(
&'life0 mut self,
global: Global<'base>,
frame: &'life1 mut AsyncGcFrame<'base>
) -> Pin<Box<dyn Future<Output = JlrsResult<Self::T>> + 'async_trait>> where
'base: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn run<'base, 'life0, 'life1, 'async_trait>(
&'life0 mut self,
global: Global<'base>,
frame: &'life1 mut AsyncGcFrame<'base>
) -> Pin<Box<dyn Future<Output = JlrsResult<Self::T>> + 'async_trait>> where
'base: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
The entrypoint of a task. You can use the Global
and AsyncGcFrame
to call arbitrary
functions from Julia. Additionally, CallAsync::call_async
can be used to call a function
on another thread and allow other tasks to progress while awaiting the result.
Implementations that don’t use CallAsync::call_async
will block the runtime during
execution.
Provided methods
fn return_channel(&self) -> Option<&Self::R>
fn return_channel(&self) -> Option<&Self::R>
The return channel for this task, or None
if the result doesn’t need to be returned.
Returns None
by default.