pub struct LightWorkset {
layout: LightCacheLayout,
chunks: LightChunkSlotArray<LightWorksetChunk>,
}Expand description
Scoped chunk admission for one light operation.
This keeps the ScalableLux cache-window admission rules without storing
long-lived borrows into chunk internals. The workset pins admitted chunk
holders, then builds short-lived read caches with locks acquired in stable
cache-slot order.
Fields§
§layout: LightCacheLayout§chunks: LightChunkSlotArray<LightWorksetChunk>Implementations§
Source§impl LightWorkset
impl LightWorkset
Sourcepub fn setup(
layout: LightCacheLayout,
radius: LightCacheSetupRadius,
relaxed: bool,
chunk_for_lighting: impl FnMut(ChunkPos) -> Option<Arc<ChunkHolder>>,
can_use_chunk: impl FnMut(&Chunk) -> bool,
) -> Result<Self, LightWorksetSetupError>
pub fn setup( layout: LightCacheLayout, radius: LightCacheSetupRadius, relaxed: bool, chunk_for_lighting: impl FnMut(ChunkPos) -> Option<Arc<ChunkHolder>>, can_use_chunk: impl FnMut(&Chunk) -> bool, ) -> Result<Self, LightWorksetSetupError>
Creates a scoped cache window by scanning chunks in ScalableLux setup order.
Sourcepub fn setup_with_scopes(
layout: LightCacheLayout,
radius: LightCacheSetupRadius,
relaxed: bool,
chunk_for_lighting: impl FnMut(ChunkPos) -> Option<Arc<ChunkHolder>>,
can_use_chunk: impl FnMut(CachedLightChunk, &ChunkHolder, &Chunk) -> (bool, bool),
) -> Result<Self, LightWorksetSetupError>
pub fn setup_with_scopes( layout: LightCacheLayout, radius: LightCacheSetupRadius, relaxed: bool, chunk_for_lighting: impl FnMut(ChunkPos) -> Option<Arc<ChunkHolder>>, can_use_chunk: impl FnMut(CachedLightChunk, &ChunkHolder, &Chunk) -> (bool, bool), ) -> Result<Self, LightWorksetSetupError>
Creates a scoped cache window with separate section-read and light-write admission.
Sourcepub const fn layout(&self) -> LightCacheLayout
pub const fn layout(&self) -> LightCacheLayout
Returns this workset’s cache layout.
Sourcepub fn chunk_holder(
&self,
cached_chunk: CachedLightChunk,
) -> Option<&Arc<ChunkHolder>>
pub fn chunk_holder( &self, cached_chunk: CachedLightChunk, ) -> Option<&Arc<ChunkHolder>>
Returns the holder for a cached chunk slot.
Sourcepub fn can_read_sections(&self, cached_chunk: CachedLightChunk) -> bool
pub fn can_read_sections(&self, cached_chunk: CachedLightChunk) -> bool
Returns whether a cached chunk was admitted for section reads.
Sourcepub fn can_write_light(&self, cached_chunk: CachedLightChunk) -> bool
pub fn can_write_light(&self, cached_chunk: CachedLightChunk) -> bool
Returns whether a cached chunk was admitted for light writes.
Sourcepub fn with_chunk_read_cache<R>(
&self,
f: impl FnOnce(&LightChunkReadCache<'_>) -> R,
) -> R
pub fn with_chunk_read_cache<R>( &self, f: impl FnOnce(&LightChunkReadCache<'_>) -> R, ) -> R
Builds a chunk-read cache for the duration of f.
The workset keeps holder Arcs alive, while this cache borrows the chunks
installed in their stable OnceLock storage for the scoped operation.
fn try_get_holder( cached_chunk: CachedLightChunk, relaxed: bool, chunk_for_lighting: &mut impl FnMut(ChunkPos) -> Option<Arc<ChunkHolder>>, ) -> Result<Option<Arc<ChunkHolder>>, LightWorksetSetupError>
Auto Trait Implementations§
impl !RefUnwindSafe for LightWorkset
impl !UnwindSafe for LightWorkset
impl Freeze for LightWorkset
impl Send for LightWorkset
impl Sync for LightWorkset
impl Unpin for LightWorkset
impl UnsafeUnpin for LightWorkset
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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 moreArc<SyncMutex<>>