A trait for types that can be spawned onto a [`ThreadPool`]. It is implemented for: Closures that satisfy `for<'worker> FnOnce(&'worker Worker) + Send + 'static`. Futures that satisfy `Future + Send + 'static` where `T: Send + 'static`. Closures return `()` when spawned, but futures return a [`Task`]. # Compile Errors Due to a bug in rustc, you may be given errors when using clos
| 464 | where |
| 465 | F: FnOnce(&Worker) -> R, |
| 466 | { |
| 467 | self.get_worker(|worker| match worker { |
| 468 | Some(worker) => func(worker), |
| 469 | None => self.with_worker_cold(func), |
| 470 | }) |
| 471 | } |
| 472 | |
| 473 | /// The cold branch of `with_worker`. |
| 474 | /// |
| 475 | /// Requests membership in the thread pool, and then activates that |
| 476 | /// membership to get a new local worker handle. If the thread pool is full |
| 477 | /// (there are already 32 members) this blocks. |
| 478 | #[cold] |
| 479 | fn with_worker_cold<F, R>(&'static self, func: F) -> R |
| 480 | where |
| 481 | F: FnOnce(&Worker) -> R, |
| 482 | { |
| 483 | let membership = self.enroll(); |
| 484 | membership.activate(func) |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | // ----------------------------------------------------------------------------- |
nothing calls this directly
no outgoing calls
no test coverage detected