Add a WIP thread pool example

This commit is contained in:
Stjepan Glavina 2020-02-06 12:18:59 +01:00
parent df1bbfd865
commit b9ab3aed2f
1 changed files with 15 additions and 0 deletions

15
examples/thread-pool.rs Normal file
View File

@ -0,0 +1,15 @@
fn main() {
// Start a threadpool.
// for _ in 0..num_cpus::get().max(1) {
// thread::spawn(|| smol::run(future::pending()));
// }
// Start a stoppable threadpool.
// let mut pool = vec![];
// for _ in 0..num_cpus::get().max(1) {
// let (s, r) = oneshot::channel<()>();
// pool.push(s);
// thread::spawn(|| smol::run(async move { drop(r.await) }));
// }
// drop(pool); // stops the threadpool!
}