tpx
Schedule and run coroutines.
- WIP
- Use a thread pool to spawn lightweight coroutines
- Meant for CPU-bound tasks that work cooperatively
- Continuation-passing style: callbacks automatically scheduled to run in a pool
of work-stealing threads
- Super simple and fast. No async runtime.
Example
use std::{thread::sleep, time::Duration};
use tpx::{continue_with, Ctn::DONE, Executor};
fn main() {
let exec = Executor::init();
for i in 0..3 {
exec.spawn(move || {
println!("Hello from task {i}");
let j = i * 3;
sleep(Duration::from_millis(123));
continue_with(move || {
println!("Hello from continuation {i}: Result: {j}");
DONE
})
});
}
sleep(Duration::from_secs(3));
}