pub struct Timer { /* private fields */ }
Implementations§
Source§impl Timer
impl Timer
Sourcepub fn background() -> Self
pub fn background() -> Self
Create a default, independent timer with no time duration limit.
Sourcepub fn with_timeout(timeout: Duration) -> Self
pub fn with_timeout(timeout: Duration) -> Self
Specify the maximum execution duration for the Timer
.
Trait Implementations§
Source§impl Context for Timer
impl Context for Timer
Source§fn deadline<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Option<Instant>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn deadline<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Option<Instant>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
return the deadline
time::Instant
of this context.
return None when this context doesn’t have deadline.Source§fn cancel<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn cancel<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
cancel this context, then cancel all its childs.
Source§fn is_cancelled<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn is_cancelled<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
check whether this context is cancelled or not.
Source§fn is_timeout<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn is_timeout<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
check whether this context is timeout or not.
Source§fn spawn<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Self> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn spawn<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Self> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
spawn a new child context. Read more
Source§fn spawn_with_timeout<'life0, 'async_trait>(
&'life0 self,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Self> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn spawn_with_timeout<'life0, 'async_trait>(
&'life0 self,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Self> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
spawn a new child context, with a new timeout parameter. Read more
Auto Trait Implementations§
impl Freeze for Timer
impl !RefUnwindSafe for Timer
impl Send for Timer
impl Sync for Timer
impl Unpin for Timer
impl !UnwindSafe for Timer
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
Mutably borrows from an owned value. Read more