/// The runtime's own state, for programs that adapt to it. /// A blocking pool (ADR 0005, Revision 2): its threads (at most this many /// of its calls run at once), the calls running, and the calls waiting /// for a thread. pub type PoolStats { PoolStats(size: Int, running: Int, queued: Int) } /// The two blocking pools: `cpu` runs externs declared `blocking` or /// `blocking(cpu)`, `io` those declared `blocking(io)`. pub type BlockingStats { BlockingStats(cpu: PoolStats, io: PoolStats) } /// The blocking pools now. A program can refuse work early when calls /// queue up (answer 429 when too many password checks wait, say) instead /// of letting callers wait. The interpreter runs blocking calls inline: /// there, nothing runs or waits on a pool. pub fn blocking_stats :: -> BlockingStats / { let (cpu, io) = blocking_stats_raw () BlockingStats(cpu: pool cpu, io: pool io) } fn pool :: raw: (Int, Int, Int) -> PoolStats { PoolStats(size: raw.0, running: raw.1, queued: raw.2) } @extern c "tl_runtime_blocking_stats" fn blocking_stats_raw :: -> ((Int, Int, Int), (Int, Int, Int)) /