pub struct ClassifierPool { /* private fields */ }Expand description
Bounded pool of N independently-loaded classifiers.
See module docs for the invariants this type enforces.
Implementations§
Source§impl ClassifierPool
impl ClassifierPool
Sourcepub fn new<L>(capacity: usize, loader: L) -> Result<Self, NlError>
pub fn new<L>(capacity: usize, loader: L) -> Result<Self, NlError>
Build a pool of capacity independently-loaded classifiers.
capacity is clamped into [POOL_MIN, POOL_MAX] (NFR-2).
Calls loader exactly capacity times — see the pool
invariant in the module-level docs.
§Errors
Propagates the first NlError returned by loader. On
failure the partially-built pool is dropped, releasing any
already-loaded classifiers.
Sourcepub fn acquire(&self) -> PoolGuard<'_>
pub fn acquire(&self) -> PoolGuard<'_>
Acquire a slot, blocking the current thread until one is
available. The returned PoolGuard returns the slot on
drop (panic-safe via scopeguard::guard).
§Panics
Panics only if the channel has been disconnected — which is
impossible during normal use because the ClassifierPool
itself owns the receiver, so the only way to disconnect it is
to drop the pool. Acquiring a guard on a dropped pool would be
a use-after-free style bug.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ClassifierPool
impl RefUnwindSafe for ClassifierPool
impl Send for ClassifierPool
impl Sync for ClassifierPool
impl Unpin for ClassifierPool
impl UnsafeUnpin for ClassifierPool
impl UnwindSafe for ClassifierPool
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
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>
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>
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