tobogganSe connecter

louise

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

28 lignes · 1112 octetsBrut · Historique
1/// The runtime's own state, for programs that adapt to it.
2
3/// A blocking pool (ADR 0005, Revision 2): its threads (at most this many
4/// of its calls run at once), the calls running, and the calls waiting
5/// for a thread.
6pub type PoolStats { PoolStats(size: Int, running: Int, queued: Int) }
7
8/// The two blocking pools: `cpu` runs externs declared `blocking` or
9/// `blocking(cpu)`, `io` those declared `blocking(io)`.
10pub type BlockingStats { BlockingStats(cpu: PoolStats, io: PoolStats) }
11
12/// The blocking pools now. A program can refuse work early when calls
13/// queue up (answer 429 when too many password checks wait, say) instead
14/// of letting callers wait. The interpreter runs blocking calls inline:
15/// there, nothing runs or waits on a pool.
16pub fn blocking_stats :: -> BlockingStats / <io>
17{
18 let (cpu, io) = blocking_stats_raw ()
19 BlockingStats(cpu: pool cpu, io: pool io)
20}
21
22fn pool :: raw: (Int, Int, Int) -> PoolStats
23{
24 PoolStats(size: raw.0, running: raw.1, queued: raw.2)
25}
26
27@extern c "tl_runtime_blocking_stats"
28fn blocking_stats_raw :: -> ((Int, Int, Int), (Int, Int, Int)) / <io>