pub struct ResourceGovernor { /* private fields */ }Expand description
Process/engine resource governor.
Implementations§
Source§impl ResourceGovernor
impl ResourceGovernor
Sourcepub fn try_new(config: GovernorConfig) -> Result<Self>
pub fn try_new(config: GovernorConfig) -> Result<Self>
Build a governor after validating config (JOE-1917).
Sourcepub fn new(config: GovernorConfig) -> Self
pub fn new(config: GovernorConfig) -> Self
Build a governor. Panics if config fails validation.
Prefer Self::try_new at public SDK boundaries.
pub fn config(&self) -> &GovernorConfig
Sourcepub fn process_global() -> Arc<Self> ⓘ
pub fn process_global() -> Arc<Self> ⓘ
Process-wide default governor (desktop profile).
Isolated engines can construct their own ResourceGovernor instead.
Sourcepub fn acquire(
self: &Arc<Self>,
kind: PermitKind,
ctx: Option<&OpContext>,
) -> Result<ResourcePermit>
pub fn acquire( self: &Arc<Self>, kind: PermitKind, ctx: Option<&OpContext>, ) -> Result<ResourcePermit>
Acquire a single permit, optionally waiting with cancel/deadline.
Sourcepub fn acquire_stt(
self: &Arc<Self>,
cpu_threads: usize,
memory: u64,
ctx: Option<&OpContext>,
) -> Result<ResourcePermit>
pub fn acquire_stt( self: &Arc<Self>, cpu_threads: usize, memory: u64, ctx: Option<&OpContext>, ) -> Result<ResourcePermit>
Acquire STT permit + blocking permit + CPU thread budget (+ optional memory).
Acquisition order is fixed (memory → STT → blocking → CPU) under a brief mutex so concurrent multi-resource acquires cannot deadlock. The mutex is not held across sleep/wait.
Sourcepub fn acquire_tts(
self: &Arc<Self>,
memory: u64,
ctx: Option<&OpContext>,
) -> Result<ResourcePermit>
pub fn acquire_tts( self: &Arc<Self>, memory: u64, ctx: Option<&OpContext>, ) -> Result<ResourcePermit>
Acquire local TTS + blocking permits (+ optional memory).
Sourcepub fn recommend_stt_threads(&self) -> usize
pub fn recommend_stt_threads(&self) -> usize
How many Whisper threads a new STT job should use given remaining budget.
pub fn stats(&self) -> GovernorStats
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ResourceGovernor
impl RefUnwindSafe for ResourceGovernor
impl Send for ResourceGovernor
impl Sync for ResourceGovernor
impl Unpin for ResourceGovernor
impl UnsafeUnpin for ResourceGovernor
impl UnwindSafe for ResourceGovernor
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