pub struct Pool { /* private fields */ }Expand description
A worker pool that executes tasks on the same processor that spawned them.
This ensures optimal cache locality and minimizes cross-processor data movement.
§Lifetime
When the pool is dropped:
- All worker threads are signaled to shut down.
- The drop blocks until all currently-executing tasks complete.
- Any queued tasks that have not started are abandoned.
To ensure all tasks complete, await their JoinHandles before dropping
the pool.
§Example
use vicinal::Pool;
let pool = Pool::new();
let scheduler = pool.scheduler();
let handle = scheduler.spawn(|| 42);
assert_eq!(handle.await, 42);Implementations§
Source§impl Pool
impl Pool
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new pool with default settings.
Use Pool::builder() for custom configuration.
Sourcepub fn builder() -> PoolBuilder
pub fn builder() -> PoolBuilder
Creates a builder for configuring the pool.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Pool
impl !RefUnwindSafe for Pool
impl Send for Pool
impl Sync for Pool
impl Unpin for Pool
impl !UnwindSafe 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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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