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, timeout: Duration) -> usize
pub async fn terminate_all_async(&self, timeout: Duration) -> usize
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 moreAuto Trait Implementations§
impl Freeze for TaskController
impl RefUnwindSafe for TaskController
impl Send for TaskController
impl Sync for TaskController
impl Unpin for TaskController
impl UnwindSafe for TaskController
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)