pub struct TaskController { /* private fields */ }
Implementations§
Source§impl TaskController
impl TaskController
Sourcepub fn spawn_abortable<F, T>(&self, future: F) -> JoinHandle<()>
pub fn spawn_abortable<F, T>(&self, future: F) -> JoinHandle<()>
Spawns a task that can be later terminated by call to TaskController::terminate_all()
.
Task output is ignored.
Sourcepub fn spawn_abortable_with_rt<F, T>(
&self,
rt: ZRuntime,
future: F,
) -> JoinHandle<()>
pub fn spawn_abortable_with_rt<F, T>( &self, rt: ZRuntime, future: F, ) -> JoinHandle<()>
Spawns a task using a specified runtime that can be later terminated by call to TaskController::terminate_all()
.
Task output is ignored.
pub fn get_cancellation_token(&self) -> CancellationToken
Sourcepub fn spawn<F, T>(&self, future: F) -> JoinHandle<()>
pub fn spawn<F, T>(&self, future: F) -> JoinHandle<()>
Spawns a task that can be cancelled via cancellation of a token obtained by TaskController::get_cancellation_token()
,
or that can run to completion in finite amount of time.
It can be later terminated by call to TaskController::terminate_all()
.
Sourcepub fn spawn_with_rt<F, T>(&self, rt: ZRuntime, future: F) -> JoinHandle<()>
pub fn spawn_with_rt<F, T>(&self, rt: ZRuntime, future: F) -> JoinHandle<()>
Spawns a task that can be cancelled via cancellation of a token obtained by TaskController::get_cancellation_token()
,
or that can run to completion in finite amount of time, using a specified runtime.
It can be later aborted by call to TaskController::terminate_all()
.
Sourcepub fn terminate_all(&self, timeout: Duration) -> usize
pub fn terminate_all(&self, timeout: Duration) -> usize
Attempts tp terminate all previously spawned tasks
The caller must ensure that all tasks spawned with TaskController::spawn()
or TaskController::spawn_with_rt()
can yield in finite amount of time either because they will run to completion
or due to cancellation of token acquired via TaskController::get_cancellation_token()
.
Tasks spawned with TaskController::spawn_abortable()
or TaskController::spawn_abortable_with_rt()
will be aborted (i.e. terminated upon next await call).
The call blocks until all tasks yield or timeout duration expires.
Returns 0 in case of success, number of non terminated tasks otherwise.
Sourcepub async fn terminate_all_async(&self)
pub async fn terminate_all_async(&self)
Async version of TaskController::terminate_all()
.
Trait Implementations§
Source§impl Clone for TaskController
impl Clone for TaskController
Source§fn clone(&self) -> TaskController
fn clone(&self) -> TaskController
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more