
louise
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
Dernier runRéussi#1197 · main · 10 min 35 s
1Étoiles
0Forks
0Issues
| 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. |
| 6 | pub 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)`. |
| 10 | pub 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. |
| 16 | pub fn blocking_stats :: -> BlockingStats / <io> |
| 17 | { |
| 18 | let (cpu, io) = blocking_stats_raw () |
| 19 | BlockingStats(cpu: pool cpu, io: pool io) |
| 20 | } |
| 21 | |
| 22 | fn 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" |
| 28 | fn blocking_stats_raw :: -> ((Int, Int, Int), (Int, Int, Int)) / <io> |