pub trait AsWorkerPool<W>: From<Vec<W>> + Into<Vec<W>> {
// Required methods
fn new() -> Self;
fn with_len(len: usize) -> Self;
fn len(&self) -> usize;
fn append(&mut self, worker: W);
// Provided methods
fn with_all_cpus() -> Self { ... }
fn is_empty(&self) -> bool { ... }
}Expand description
Common interface for worker pool implementations.
Required Methods§
Sourcefn new() -> Self
fn new() -> Self
Creates an empty worker pool.
§Examples
use my_ecs::prelude::*;
let pool = WorkerPool::new();
assert!(pool.is_empty());Provided Methods§
Sourcefn with_all_cpus() -> Self
fn with_all_cpus() -> Self
Creates worker pool with workers as many as number of available logical cpus.
Number of logical cpus depends on platform which this crate runs on. This method guarantees the returned worker pool to have at least one worker in it even if it failed to get the number of logical cpus.
§Examples
use my_ecs::prelude::*;
let pool = WorkerPool::with_all_cpus();
assert!(!pool.is_empty());Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.