pub struct Pool { /* private fields */ }Expand description
A fixed set of worker threads that Exec tokens place work on.
Pool is the only way to make a pool. It wraps the scheduler privately: no
scheduler type appears in any signature, there is no constructor from an
external pool and no accessor returning one. The pool’s owner keeps the
Pool and mints tokens from it with Exec::new.
Dropping a Pool shuts its workers down.
§Examples
use strided_exec::Pool;
let pool = Pool::builder().threads(2).thread_name(|i| format!("w{i}")).build()?;
assert!(pool.width().get() <= 2);Implementations§
Source§impl Pool
impl Pool
Sourcepub fn builder() -> PoolBuilder
pub fn builder() -> PoolBuilder
Starts configuring a pool.
§Examples
let pool = strided_exec::Pool::builder().threads(1).build()?;
assert_eq!(pool.width().get(), 1);Sourcepub fn width(&self) -> NonZeroUsize
pub fn width(&self) -> NonZeroUsize
Number of worker threads, the largest budget a token can have.
Without the parallel feature this is always 1.
§Examples
let pool = strided_exec::Pool::builder().threads(1).build()?;
assert_eq!(pool.width().get(), 1);Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Pool
impl !UnwindSafe for Pool
impl Freeze for Pool
impl Send for Pool
impl Sync for Pool
impl Unpin for Pool
impl UnsafeUnpin for Pool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more