[−][src]Enum osaka::Task
Something that can be activated
An osaka task is usually constructed by adding the osaka macro to a function, like so:
#[osaka] fn the_answer(poll: osaka::Poll) -> u32 { let oracle = Oracle{}; let token = poll.register(oracle); if oracle.is_ready() { return 42; } else { yield poll.again(token); } }
Variants
Later
Fields of Later
Immediate
Fields of Immediate
r: Option<R>
Methods
impl<R> Task<R>
[src]
pub fn run(&mut self) -> R
[src]
run a task to completion, blocking the current thread.
this is not re-entrant, meaning you cannot call this function from some callback. It is also not thread safe. Basically only ever call this once, prefferably in main.
pub fn new(f: Box<dyn Future<R>>, a: Again) -> Self
[src]
the brave may construct a Task manually from a Future
the passed Again instance needs to already contain an activation source, or the task will never be executed
for example:
struct Santa { poll: Poll } impl Future for Santa { fn poll(&mut self) -> FutureResult<Present> { FutureResult::Again(self.poll.never()) } } fn main() { let poll = Poll::new(); let santa = Santa{poll}; santa.run().unwrap(); }
pub fn wakeup_now(&mut self)
[src]
force a wakeup the next time activate
is called. This is for a poor implementation of
channels and you should probably not use this.
pub fn immediate(t: R) -> Task<R>
[src]
Trait Implementations
impl<R> Future<R> for Task<R>
[src]
fn poll(&mut self) -> FutureResult<R>
[src]
this is called by the execution engine, or a sync macro.
you can call this by hand, but it won't actually do anything unless the task contains a token that is ready, or has an expired deadline
impl<E: Debug> Termination for Task<Result<(), E>>
[src]
Auto Trait Implementations
Blanket Implementations
impl<R, X> Future for X where
X: Generator<Yield = Again, Return = R> + Unpin,
[src]
X: Generator<Yield = Again, Return = R> + Unpin,
fn poll(&mut Self) -> FutureResult<R>
[src]
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,