Skip to main content

TimeoutOn

Struct TimeoutOn 

pub struct TimeoutOn<A: TimerAccess, F: Future> { /* private fields */ }
Expand description

按业务优先组合;F不要求Unpin/Send/Sync/’static,不强迫额外装箱。 每次轮询(poll)先推进业务,业务Ready优先返回结果,Pending后才准备并推进计时。 正常到期返回TimeoutError::Elapsed,计时设施失败返回Timer;再次轮询不重置截止时间。 业务完成时撤销计时兴趣;到期或计时失败返回前合法析构(drop)本包装持有的业务异步计算(Future)。 若F只是后台任务(Task)的结果句柄,释放F沿原句柄约定,不等于取消后台任务。

Implementations§

§

impl<A: TimerAccess, F: Future> TimeoutOn<A, F>

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

只保存原业务异步计算(Future)、计时访问及时长,不取时、不准备或提交定时登记。 真正计时准备从首次业务轮询(poll)返回Pending后开始;业务先完成不产生计时登记。

Trait Implementations§

§

impl<A: TimerAccess, F: Future> Future for TimeoutOn<A, F>

§

type Output = Result<<F as Future>::Output, TimeoutError>

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

Auto Trait Implementations§

§

impl<A, F> !RefUnwindSafe for TimeoutOn<A, F>

§

impl<A, F> !UnwindSafe for TimeoutOn<A, F>

§

impl<A, F> Forget for TimeoutOn<A, F>

§

impl<A, F> Freeze for TimeoutOn<A, F>

§

impl<A, F> Move for TimeoutOn<A, F>

§

impl<A, F> Send for TimeoutOn<A, F>
where Option<F>: Send, Option<A>: Send, Option<Timeout<A>>: Send,

§

impl<A, F> Sync for TimeoutOn<A, F>
where Option<F>: Sync, Option<A>: Sync, Option<Timeout<A>>: Sync,

§

impl<A, F> Unpin for TimeoutOn<A, F>
where Option<F>: Unpin, Option<A>: Unpin, Option<Timeout<A>>: Unpin,

§

impl<A, F> UnsafeUnpin for TimeoutOn<A, F>

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<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.