4 ms·
Nothing so fancy. Each worker thread runs in a loop executing a queue of jobs. On every iteration it sets an atomic progress flag to true. The runtime in whi
by Freaky 6y ago
Nothing so fancy.
Each worker thread runs in a loop executing a queue of jobs. On every iteration it sets an atomic progress flag to true.
The runtime in which it's contained polls its workers every 1-10ms, atomically swapping in false and checking to see if the previous value was also false - if so, it steals its task queue and spins up another worker to execute it.
https://github.com/async-rs/async-std/blob/ceba324bef9641d61239ed68a2f6671f59fa2831/src/rt/runtime.rs#L107-L153 https://github.com/async-rs/async-std/blob/ceba324bef9641d61...