pub struct SharedClassifier(/* private fields */);Expand description
Shared, lockable handle to a single loaded IntentClassifier.
One handle = one loaded model session. Cloning is O(1) and
recirculates the same underlying session; it does NOT duplicate
model weights or fan out to a parallel session. To serve N
concurrent inferences, allocate N independent
SharedClassifier instances (one IntentClassifier::load
each) — see NL07’s ClassifierPool.
Implementations§
Sourcepub fn new(classifier: IntentClassifier) -> Self
pub fn new(classifier: IntentClassifier) -> Self
Wrap an already-loaded IntentClassifier for shared,
lock-mediated access.
Sourcepub fn lock(&self) -> MutexGuard<'_, IntentClassifier>
pub fn lock(&self) -> MutexGuard<'_, IntentClassifier>
Acquire the lock for &mut access (required by
ort::session::Session::run).
Use the returned guard within a small scope; do NOT hold it
across .await points (the wrapping crate is sync-only anyway,
but this rule still applies to any future async wrapper).
The returned parking_lot::MutexGuard is itself #[must_use],
so dropping it on the floor is a clippy warning at the call
site.
Sourcepub fn identity(&self) -> usize
pub fn identity(&self) -> usize
Stable identity for this slot’s underlying Arc<Mutex<_>>.
Distinct loaded sessions = distinct identities. Used by the
NL07 integration test
(sqry-nl/tests/pool_concurrent_load.rs) to assert that the
pool’s N slots map to N independent IntentClassifier
instances. Cloning a SharedClassifier re-circulates the
same Arc and therefore returns the same identity.
Trait Implementations§
Source§fn clone(&self) -> SharedClassifier
fn clone(&self) -> SharedClassifier
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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