std1.0.0-beta-7 SafeC docs

Module async::host

#include <std/async/host.h> source

async: hosted parking and block_on

HostPark is the Park source (std/async/executor.h) for a hosted program with no I/O to wait for: the OS monotonic clock, and a condition variable to sleep on until the next timer deadline or a wake from another thread. block_on(&fut) runs a future to completion on the calling thread with a fresh LocalExecutor and a HostPark — the usual way into async code from main() (Rust's futures::executor::block_on):

struct Fetch f = Fetch::new();
int n = block_on(&f);

For async I/O use std/async/net.h's Runtime instead (its IoDriver parks in the OS readiness queue); for parallelism std/async/pool.h's ThreadPool. Hosted targets only (it uses std/thread.h and std/time.h).

Structs

HostPark

Functions

async_mono_msMilliseconds of the OS monotonic clock.
block_onRun 'fut' to completion on this thread and return its value. Tasks it spawns (async_spawn) run meanwhile, on the same thread; any still running when 'fut' finishes are abandoned with the executor.