pub struct PoolBuilder { /* private fields */ }Expand description
Implementations§
Source§impl PoolBuilder
impl PoolBuilder
Sourcepub fn thread_name(self, f: impl Fn(usize) -> String + 'static) -> Self
pub fn thread_name(self, f: impl Fn(usize) -> String + 'static) -> Self
Names the workers; the closure receives the worker index.
§Examples
let pool = strided_exec::Pool::builder()
.threads(1)
.thread_name(|i| format!("my-pool-{i}"))
.build()?;Sourcepub fn stack_size(self, bytes: usize) -> Self
pub fn stack_size(self, bytes: usize) -> Self
Worker stack size in bytes. Defaults to 16 MiB, sized for recursive LU.
§Examples
let pool = strided_exec::Pool::builder().threads(1).stack_size(4 << 20).build()?;Sourcepub fn on_start(self, f: impl Fn(usize) + Send + Sync + 'static) -> Self
pub fn on_start(self, f: impl Fn(usize) + Send + Sync + 'static) -> Self
Hook run on each worker when it starts, with the worker index.
Typical use is pinning the worker to a core. The hook is not called
without the parallel feature, which starts no workers.
§Examples
let pool = strided_exec::Pool::builder().threads(1).on_start(|_| {}).build()?;Sourcepub fn build(self) -> Result<Pool, Error>
pub fn build(self) -> Result<Pool, Error>
Starts the workers.
Without the parallel feature no thread is started and the pool has
width 1.
§Errors
Error::ZeroThreads when threads(0) was requested, and
Error::PoolBuild when the workers cannot be started.
§Examples
let pool = strided_exec::Pool::builder().threads(2).build()?;
assert!(pool.width().get() <= 2);Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for PoolBuilder
impl !Send for PoolBuilder
impl !Sync for PoolBuilder
impl !UnwindSafe for PoolBuilder
impl Freeze for PoolBuilder
impl Unpin for PoolBuilder
impl UnsafeUnpin for PoolBuilder
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