pub struct ChunkTicketManager {
tickets: FxHashMap<ChunkPos, SmallVec<[ChunkTicket; 4]>>,
levels: FxHashMap<ChunkPos, ChunkTicketLevel>,
simulation_levels: FxHashMap<ChunkPos, ChunkTicketLevel>,
dirty: bool,
changes: Vec<LevelChange>,
}Expand description
Chunk ticket propagation. Lower levels = higher priority. Multiple tickets per position supported.
Fields§
§tickets: FxHashMap<ChunkPos, SmallVec<[ChunkTicket; 4]>>§levels: FxHashMap<ChunkPos, ChunkTicketLevel>§simulation_levels: FxHashMap<ChunkPos, ChunkTicketLevel>§dirty: bool§changes: Vec<LevelChange>Tracks changes from the last run_all_updates() call.
Implementations§
Source§impl ChunkTicketManager
impl ChunkTicketManager
pub fn new() -> Self
Sourcepub fn add_ticket(&mut self, pos: ChunkPos, ticket: ChunkTicket)
pub fn add_ticket(&mut self, pos: ChunkPos, ticket: ChunkTicket)
Adds a ticket source. Multiple tickets can exist at the same position.
Sourcepub fn remove_ticket(&mut self, pos: ChunkPos, ticket: ChunkTicket) -> bool
pub fn remove_ticket(&mut self, pos: ChunkPos, ticket: ChunkTicket) -> bool
Removes one ticket matching (pos, ticket). Returns true if found.
Sourcepub fn remove_all_tickets_at(&mut self, pos: ChunkPos) -> bool
pub fn remove_all_tickets_at(&mut self, pos: ChunkPos) -> bool
Removes all tickets at position. Returns true if any were present.
Sourcepub fn get_ticket(&self, pos: ChunkPos) -> Option<ChunkTicketLevel>
pub fn get_ticket(&self, pos: ChunkPos) -> Option<ChunkTicketLevel>
Returns the minimum ticket level at position.
Sourcepub fn tickets_at(
&self,
pos: ChunkPos,
) -> impl Iterator<Item = ChunkTicket> + '_
pub fn tickets_at( &self, pos: ChunkPos, ) -> impl Iterator<Item = ChunkTicket> + '_
Iterator over the tickets currently held at pos.
Sourcepub fn tickets(&self) -> impl Iterator<Item = (ChunkPos, ChunkTicketLevel)> + '_
pub fn tickets(&self) -> impl Iterator<Item = (ChunkPos, ChunkTicketLevel)> + '_
Iterator over (position, min_level) for all ticket sources.
pub fn ticket_count(&self) -> usize
pub fn ticket_position_count(&self) -> usize
Sourcepub fn run_all_updates(&mut self) -> &[LevelChange]
pub fn run_all_updates(&mut self) -> &[LevelChange]
Propagates all tickets. Only runs if dirty. Returns a slice of changes (added/updated/removed levels).
Sourcepub(crate) fn take_changes(&mut self) -> Vec<LevelChange>
pub(crate) fn take_changes(&mut self) -> Vec<LevelChange>
Takes the change list produced by the last propagation pass.
Sourcepub(crate) fn recycle_changes(&mut self, changes: Vec<LevelChange>)
pub(crate) fn recycle_changes(&mut self, changes: Vec<LevelChange>)
Returns a drained change buffer for reuse by the next propagation pass.
fn record_simulation_only_changes( &mut self, old_levels: &FxHashMap<ChunkPos, ChunkTicketLevel>, old_simulation_levels: &FxHashMap<ChunkPos, ChunkTicketLevel>, )
Sourcepub fn get_level(&self, pos: ChunkPos) -> Option<ChunkTicketLevel>
pub fn get_level(&self, pos: ChunkPos) -> Option<ChunkTicketLevel>
Returns the propagated level at position. Call run_all_updates() first.
Sourcepub fn get_simulation_level(&self, pos: ChunkPos) -> Option<ChunkTicketLevel>
pub fn get_simulation_level(&self, pos: ChunkPos) -> Option<ChunkTicketLevel>
Returns the propagated simulation level at position. Call run_all_updates() first.
fn clear(&mut self)
pub fn iter_levels( &self, ) -> impl Iterator<Item = (ChunkPos, ChunkTicketLevel)> + '_
pub fn iter_simulation_levels( &self, ) -> impl Iterator<Item = (ChunkPos, ChunkTicketLevel)> + '_
Trait Implementations§
Source§impl Debug for ChunkTicketManager
impl Debug for ChunkTicketManager
Auto Trait Implementations§
impl Freeze for ChunkTicketManager
impl RefUnwindSafe for ChunkTicketManager
impl Send for ChunkTicketManager
impl Sync for ChunkTicketManager
impl Unpin for ChunkTicketManager
impl UnsafeUnpin for ChunkTicketManager
impl UnwindSafe for ChunkTicketManager
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<>>