Skip to content
CryoCryo home
Stdlibfuture

poll

import std::future::poll; · source

Types

Poll<T>

type enum Poll<T> {
    Ready(T);
    Pending;
}

implement enum Poll<T> {
    is_ready(&this) -> boolean;
    is_pending(&this) -> boolean;
    ![sink]
    into_ready(&this) -> T;
}

The result of one poll call. Pending means "not yet — I have arranged to be woken"; Ready(v) means the value is available and the future is done. into_ready unwraps a Poll you know is ready and panics otherwise, which is what a test driving a future by hand wants.

Variants

Variant
Ready(T)
Pending

Methods

is_ready(&this) -> boolean;

True when this is Ready. The payload is inspected by reference, so the receiver keeps ownership of it.

is_pending(&this) -> boolean;

True when this is Pending.

![sink] into_ready(&this) -> T;

Move the Ready value out. Aborts on Pending. The compiler's async lowering calls this only after an is_pending check has already returned on the Pending path, so the Pending arm here is a should-never-happen guard rather than a reachable state.