Skip to main content

RangeMap

Trait RangeMap 

Source
pub trait RangeMap: Send + Sync {
    type I: Send + Sync;

    // Provided methods
    fn is_range_all_ready(&self) -> bool { ... }
    fn is_range_ready(&self, _start: Self::I, _count: Self::I) -> Result<bool> { ... }
    fn check_range_ready_and_mark_pending(
        &self,
        _start: Self::I,
        _count: Self::I,
    ) -> Result<Option<Vec<Self::I>>> { ... }
    fn set_range_ready_and_clear_pending(
        &self,
        _start: Self::I,
        _count: Self::I,
    ) -> Result<()> { ... }
    fn clear_range_pending(&self, _start: Self::I, _count: Self::I) { ... }
    fn wait_for_range_ready(
        &self,
        _start: Self::I,
        _count: Self::I,
    ) -> Result<bool> { ... }
}
Expand description

Trait to track chunk or data readiness state.

A RangeMap object tracks readiness state of a chunk or data range, indexed by chunk index or data address. The trait methods are designed to support batch operations for improving performance by avoid frequently acquire/release locks.

Required Associated Types§

Source

type I: Send + Sync

Provided Methods§

Source

fn is_range_all_ready(&self) -> bool

Check whether all chunks or data managed by the RangeMap object are ready.

Source

fn is_range_ready(&self, _start: Self::I, _count: Self::I) -> Result<bool>

Check whether all chunks or data in the range are ready for use.

Source

fn check_range_ready_and_mark_pending( &self, _start: Self::I, _count: Self::I, ) -> Result<Option<Vec<Self::I>>>

Check whether all chunks or data in the range [start, start + count) are ready.

This function checks readiness of a range of chunks or data. If a chunk or data is both not ready and not pending(inflight), it will be marked as pending and returned. Following actions should be:

  • call set_range_ready_and_clear_pending() to mark data or chunks as ready and clear pending state.
  • clear_range_pending() to clear the pending state without marking data or chunks as ready.
  • wait_for_range_ready() to wait for all data or chunks to clear pending state, including data or chunks marked as pending by other threads.
Source

fn set_range_ready_and_clear_pending( &self, _start: Self::I, _count: Self::I, ) -> Result<()>

Mark all chunks or data in the range as ready for use.

Source

fn clear_range_pending(&self, _start: Self::I, _count: Self::I)

Clear the pending state for all chunks or data in the range.

Source

fn wait_for_range_ready(&self, _start: Self::I, _count: Self::I) -> Result<bool>

Wait for all chunks or data in the range to be ready until timeout.

Implementors§