pub struct CpuLimiter(/* private fields */);Expand description
A shared bound on concurrent CPU-heavy blocking jobs.
One CpuLimiter can be cloned and handed to many CogReaders and
Tilers so the whole process (or a whole mosaic) shares a single CPU
budget instead of each reader/tiler getting its own semaphore. Without this,
a mosaic that opens N assets would allow N × available_parallelism decode
jobs plus N independent warp pools, oversubscribing the machine and thrashing
caches under load.
Cloning is cheap (an Arc bump); all clones draw permits from the same pool.
Each default construction creates an independent pool sized to available
parallelism, or four permits if that information is unavailable. Running
blocking jobs retain their permits after request cancellation until they exit.
Deadlock-freedom invariant: a job must never hold one permit while
awaiting a second from the same limiter. Acquire → spawn_blocking → drop
must be flat, not nested. The tile pipeline upholds this by releasing a
reader’s decode permit (inside its own spawn_blocking) before the warp/
render permit is acquired — see Tiler::run_tile_cpu.
Implementations§
Source§impl CpuLimiter
impl CpuLimiter
Trait Implementations§
Source§impl Clone for CpuLimiter
impl Clone for CpuLimiter
Source§impl Debug for CpuLimiter
impl Debug for CpuLimiter
Auto Trait Implementations§
impl !RefUnwindSafe for CpuLimiter
impl !UnwindSafe for CpuLimiter
impl Freeze for CpuLimiter
impl Send for CpuLimiter
impl Sync for CpuLimiter
impl Unpin for CpuLimiter
impl UnsafeUnpin for CpuLimiter
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