Skip to main content

Timeout

Struct Timeout 

pub struct Timeout<A: TimerAccess> { /* private fields */ }
Expand description

正时长首次poll才固定截止时间并登记;零时长只让出一次。 正常到期返回Ok(());已登记项实际因取消结束才返回TimerError::Cancelled,其它未到期移除返回RegistrationRemoved。 单纯记录取消请求不表示等待结束;尚未开始登记的取消可本地结束,原准备错误仍原样返回。 正时长至少1ms且不设1s上限;构造错误保存到首次轮询(poll),尚未开始的取消可不入队结束。 零时长首次轮询让出一次并安排再唤醒,后续轮询成功;无计时登记,控制取消返回false。 完成后再轮询会恐慌(panic);释放(drop)结束兴趣并安排撤销,不等待原截止时间。

Implementations§

§

impl<A: TimerAccess> Timeout<A>

pub fn new(access: A, duration: Duration) -> Self

只检查时长并准备共享登记;不读取时钟,不提交来源。

pub fn control_handle(&self) -> TimeoutControl<A>

按需取得同一登记的共享控制;失败准备或零时长所得控制取消返回false。

Trait Implementations§

§

impl<A: TimerAccess> Drop for Timeout<A>

§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
§

impl<A: TimerAccess> Future for Timeout<A>

§

type Output = Result<(), TimerError>

The type of value produced on completion.
§

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>

Attempts to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more
§

impl<A: TimerAccess> Unpin for Timeout<A>

Auto Trait Implementations§

§

impl<A> !RefUnwindSafe for Timeout<A>

§

impl<A> !UnwindSafe for Timeout<A>

§

impl<A> Forget for Timeout<A>

§

impl<A> Freeze for Timeout<A>

§

impl<A> Move for Timeout<A>

§

impl<A> Send for Timeout<A>

§

impl<A> Sync for Timeout<A>

§

impl<A> UnsafeUnpin for Timeout<A>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<Fut> FutureExt for Fut
where Fut: Future, <Fut as Future>::Output: ResultExt,

Source§

fn attach<A>(self, attachment: A) -> FutureWithAttachment<Fut, A> ⓘ
where A: Attachment,

Adds a new printable attachment to the Report inside the Result when polling the Future. Read more
Source§

fn attach_with<A, F>(self, attachment: F) -> FutureWithLazyAttachment<Fut, F> ⓘ
where A: Attachment, F: FnOnce() -> A,

Lazily adds a new printable attachment to the Report inside the Result when polling the Future. Read more
Source§

fn attach_opaque<A>(self, attachment: A) -> FutureWithOpaqueAttachment<Fut, A> ⓘ

Adds a new attachment to the Report inside the Result when polling the Future. Read more
Source§

fn attach_opaque_with<A, F>( self, attachment: F, ) -> FutureWithLazyOpaqueAttachment<Fut, F> ⓘ
where A: OpaqueAttachment, F: FnOnce() -> A,

Lazily adds a new attachment to the Report inside the Result when polling the Future. Read more
Source§

fn change_context<C>(self, context: C) -> FutureWithContext<Fut, C> ⓘ
where C: Error + Send + Sync + 'static,

Changes the Error context of the Report inside the Result when polling the Future. Read more
Source§

fn change_context_lazy<C, F>(self, context: F) -> FutureWithLazyContext<Fut, F> ⓘ
where C: Error + Send + Sync + 'static, F: FnOnce() -> C,

Lazily changes the Error context of the Report inside the Result when polling the Future. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<F> IntoFuture for F
where F: Future,

Source§

type Output = <F as Future>::Output

The output that the future will produce on completion.
Source§

type IntoFuture = F

Which kind of future are we turning this into?
Source§

fn into_future(self) -> <F as IntoFuture>::IntoFuture

Creates a future from a value. Read more
Source§

impl<T> OpaqueAttachment for T
where T: Send + Sync + 'static,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.