pub struct WorkerPool {
catalog: &'static ContentCatalog,
limiter: Arc<WorkerLimiter>,
completed_chunks: Arc<AtomicU64>,
sims_completed: Arc<AtomicU64>,
work_tx: Option<Sender<WorkBatch>>,
result_rx: Option<Receiver<WorkBatchResult>>,
resolver: Option<Arc<DynDataResolver<'static>>>,
}Expand description
Thread pool that executes simulation chunks across available CPU cores.
Fields§
§catalog: &'static ContentCatalog§limiter: Arc<WorkerLimiter>§completed_chunks: Arc<AtomicU64>§sims_completed: Arc<AtomicU64>§work_tx: Option<Sender<WorkBatch>>§result_rx: Option<Receiver<WorkBatchResult>>§resolver: Option<Arc<DynDataResolver<'static>>>Implementations§
Source§impl WorkerPool
impl WorkerPool
pub fn new(max_workers: usize, catalog: &'static ContentCatalog) -> Self
pub fn set_resolver<R>(&mut self, resolver: R)
Sourcepub fn start(&mut self, handle: &Handle)
pub fn start(&mut self, handle: &Handle)
Starts worker tasks on handle.
§Panics
Panics if no resolver was configured before starting the pool.
pub fn result_rx(&mut self) -> Option<Receiver<WorkBatchResult>>
pub fn work_tx(&self) -> Option<Sender<WorkBatch>>
Sourcepub fn set_max_workers(&self, max_workers: usize)
pub fn set_max_workers(&self, max_workers: usize)
Update the maximum number of concurrently executing work items.
pub fn stats(&self) -> NodeStats
pub(crate) fn set_dyn_resolver( &mut self, resolver: Arc<DynDataResolver<'static>>, )
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WorkerPool
impl !RefUnwindSafe for WorkerPool
impl Send for WorkerPool
impl Sync for WorkerPool
impl Unpin for WorkerPool
impl UnsafeUnpin for WorkerPool
impl !UnwindSafe for WorkerPool
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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