Macro wookie::local[][src]

macro_rules! local {
    ($name : ident) => { ... };
    ($name : ident : $future : expr) => { ... };
}
Expand description

Wraps a future in a single-stepping executor that tracks wakers and pins it on the stack.

Unlike wookie!, does not require a global allocator at the cost of unsafe polling.

Examples

use core::task::Poll;
use wookie::local;
local!(future: async { true });
assert_eq!(unsafe { future.poll() }, Poll::Ready(true));

// you can also just give a variable name if you have one:
let future = async { true };
local!(future);
assert_eq!(unsafe { future.poll() }, Poll::Ready(true));

// we can find out about the state of wakers any time:
assert_eq!(future.cloned(), 0);
assert_eq!(future.dropped(), 0);
assert_eq!(future.woken(), 0);
// or equivalently...
future.stats().assert(0, 0, 0);