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);
}
}
Fields of Later
Fields of Immediate
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.
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();
}
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
force a wakeup the next time activate
is called. This is for a poor implementation of channels and you should probably not use this. Read more
force a wakeup the next time activate
is called. This is for a poor implementation of channels and you should probably not use this. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)