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§
Provided Methods§
Sourcefn is_range_all_ready(&self) -> bool
fn is_range_all_ready(&self) -> bool
Check whether all chunks or data managed by the RangeMap object are ready.
Sourcefn is_range_ready(&self, _start: Self::I, _count: Self::I) -> Result<bool>
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.
Sourcefn check_range_ready_and_mark_pending(
&self,
_start: Self::I,
_count: Self::I,
) -> Result<Option<Vec<Self::I>>>
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.
Sourcefn set_range_ready_and_clear_pending(
&self,
_start: Self::I,
_count: Self::I,
) -> Result<()>
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.
Sourcefn clear_range_pending(&self, _start: Self::I, _count: Self::I)
fn clear_range_pending(&self, _start: Self::I, _count: Self::I)
Clear the pending state for all chunks or data in the range.