pub trait CallAsync<'data>: Call<'data> {
unsafe fn call_async<'frame, 'value, 'life0, 'async_trait, V>(
self,
frame: &'life0 mut AsyncGcFrame<'frame>,
args: V
) -> Pin<Box<dyn Future<Output = JlrsResult<JuliaResult<'frame, 'data>>> + 'async_trait>>
where
V: AsRef<[Value<'value, 'data>]>,
'frame: 'async_trait,
'value: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait;
unsafe fn schedule_async<'frame, 'value, V>(
self,
frame: &mut AsyncGcFrame<'frame>,
args: V
) -> JlrsResult<JuliaResult<'frame, 'data, Task<'frame>>>
where
V: AsRef<[Value<'value, 'data>]>;
unsafe fn call_async_local<'frame, 'value, 'life0, 'async_trait, V>(
self,
frame: &'life0 mut AsyncGcFrame<'frame>,
args: V
) -> Pin<Box<dyn Future<Output = JlrsResult<JuliaResult<'frame, 'data>>> + 'async_trait>>
where
V: AsRef<[Value<'value, 'data>]>,
'frame: 'async_trait,
'value: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait;
unsafe fn schedule_async_local<'frame, 'value, V>(
self,
frame: &mut AsyncGcFrame<'frame>,
args: V
) -> JlrsResult<JuliaResult<'frame, 'data, Task<'frame>>>
where
V: AsRef<[Value<'value, 'data>]>;
unsafe fn call_async_main<'frame, 'value, 'life0, 'async_trait, V>(
self,
frame: &'life0 mut AsyncGcFrame<'frame>,
args: V
) -> Pin<Box<dyn Future<Output = JlrsResult<JuliaResult<'frame, 'data>>> + 'async_trait>>
where
V: AsRef<[Value<'value, 'data>]>,
'frame: 'async_trait,
'value: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait;
unsafe fn schedule_async_main<'frame, 'value, V>(
self,
frame: &mut AsyncGcFrame<'frame>,
args: V
) -> JlrsResult<JuliaResult<'frame, 'data, Task<'frame>>>
where
V: AsRef<[Value<'value, 'data>]>;
}
Expand description
This trait provides async methods to create and schedule Task
s that resolve when the
Task
has completed. Sync methods are also provided which only schedule the Task
,
those methods should only be used from PersistentTask::init
.
Required Methods
unsafe fn call_async<'frame, 'value, 'life0, 'async_trait, V>(
self,
frame: &'life0 mut AsyncGcFrame<'frame>,
args: V
) -> Pin<Box<dyn Future<Output = JlrsResult<JuliaResult<'frame, 'data>>> + 'async_trait>> where
V: AsRef<[Value<'value, 'data>]>,
'frame: 'async_trait,
'value: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
unsafe fn call_async<'frame, 'value, 'life0, 'async_trait, V>(
self,
frame: &'life0 mut AsyncGcFrame<'frame>,
args: V
) -> Pin<Box<dyn Future<Output = JlrsResult<JuliaResult<'frame, 'data>>> + 'async_trait>> where
V: AsRef<[Value<'value, 'data>]>,
'frame: 'async_trait,
'value: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Call a function on another thread with the given arguments. This method uses
Base.Threads.@spawn
to call the given function on another thread but return immediately.
While await
ing the result the async runtime can work on other tasks, the current task
resumes after the function call on the other thread completes.
Safety: this method lets you call arbitrary Julia functions which can’t be checked for
correctness. More information can be found in the safety
module.
unsafe fn schedule_async<'frame, 'value, V>(
self,
frame: &mut AsyncGcFrame<'frame>,
args: V
) -> JlrsResult<JuliaResult<'frame, 'data, Task<'frame>>> where
V: AsRef<[Value<'value, 'data>]>,
unsafe fn schedule_async<'frame, 'value, V>(
self,
frame: &mut AsyncGcFrame<'frame>,
args: V
) -> JlrsResult<JuliaResult<'frame, 'data, Task<'frame>>> where
V: AsRef<[Value<'value, 'data>]>,
Does the same thing as CallAsync::call_async
, but the task is returned rather than an
awaitable Future
. This method should only be called in PersistentTask::init
,
otherwise it’s not guaranteed this task can make progress.
Safety: this method lets you call arbitrary Julia functions which can’t be checked for
correctness. More information can be found in the safety
module.
unsafe fn call_async_local<'frame, 'value, 'life0, 'async_trait, V>(
self,
frame: &'life0 mut AsyncGcFrame<'frame>,
args: V
) -> Pin<Box<dyn Future<Output = JlrsResult<JuliaResult<'frame, 'data>>> + 'async_trait>> where
V: AsRef<[Value<'value, 'data>]>,
'frame: 'async_trait,
'value: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
unsafe fn call_async_local<'frame, 'value, 'life0, 'async_trait, V>(
self,
frame: &'life0 mut AsyncGcFrame<'frame>,
args: V
) -> Pin<Box<dyn Future<Output = JlrsResult<JuliaResult<'frame, 'data>>> + 'async_trait>> where
V: AsRef<[Value<'value, 'data>]>,
'frame: 'async_trait,
'value: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Call a function with the given arguments in an @async
block. Like call_async
, the
function is not called on the main thread, but on a separate thread that handles all
tasks created by this method. This method should only be used with functions that do very
little computational work but mostly spend their time waiting on IO.
Safety: this method lets you call arbitrary Julia functions which can’t be checked for
correctness. More information can be found in the safety
module.
unsafe fn schedule_async_local<'frame, 'value, V>(
self,
frame: &mut AsyncGcFrame<'frame>,
args: V
) -> JlrsResult<JuliaResult<'frame, 'data, Task<'frame>>> where
V: AsRef<[Value<'value, 'data>]>,
unsafe fn schedule_async_local<'frame, 'value, V>(
self,
frame: &mut AsyncGcFrame<'frame>,
args: V
) -> JlrsResult<JuliaResult<'frame, 'data, Task<'frame>>> where
V: AsRef<[Value<'value, 'data>]>,
Does the same thing as CallAsync::call_async_local
, but the task is returned rather
than an awaitable Future
. This method should only be called in PersistentTask::init
,
otherwise it’s not guaranteed this task can make progress.
Safety: this method lets you call arbitrary Julia functions which can’t be checked for
correctness. More information can be found in the safety
module.
unsafe fn call_async_main<'frame, 'value, 'life0, 'async_trait, V>(
self,
frame: &'life0 mut AsyncGcFrame<'frame>,
args: V
) -> Pin<Box<dyn Future<Output = JlrsResult<JuliaResult<'frame, 'data>>> + 'async_trait>> where
V: AsRef<[Value<'value, 'data>]>,
'frame: 'async_trait,
'value: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
unsafe fn call_async_main<'frame, 'value, 'life0, 'async_trait, V>(
self,
frame: &'life0 mut AsyncGcFrame<'frame>,
args: V
) -> Pin<Box<dyn Future<Output = JlrsResult<JuliaResult<'frame, 'data>>> + 'async_trait>> where
V: AsRef<[Value<'value, 'data>]>,
'frame: 'async_trait,
'value: 'async_trait,
V: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Call a function with the given arguments in an @async
block. The task is scheduled on
the main thread. This method should only be used with functions that must run on the main
thread. The runtime is blocked while this task is active.
Safety: this method lets you call arbitrary Julia functions which can’t be checked for
correctness. More information can be found in the safety
module.
unsafe fn schedule_async_main<'frame, 'value, V>(
self,
frame: &mut AsyncGcFrame<'frame>,
args: V
) -> JlrsResult<JuliaResult<'frame, 'data, Task<'frame>>> where
V: AsRef<[Value<'value, 'data>]>,
unsafe fn schedule_async_main<'frame, 'value, V>(
self,
frame: &mut AsyncGcFrame<'frame>,
args: V
) -> JlrsResult<JuliaResult<'frame, 'data, Task<'frame>>> where
V: AsRef<[Value<'value, 'data>]>,
Does the same thing as CallAsync::call_async_main
, but the task is returned rather
than an awaitable Future
. This method should only be called in PersistentTask::init
,
otherwise it’s not guaranteed this task can make progress.
Safety: this method lets you call arbitrary Julia functions which can’t be checked for
correctness. More information can be found in the safety
module.