pub trait EvictionPolicy<F: FrameId> {
type Error: Error;
// Required methods
fn evict(&self) -> Option<F>;
fn peek(&self) -> Option<F>;
fn touch(&self, id: F) -> Result<(), Self::Error>;
fn touch_with<T: AccessType>(
&self,
id: F,
access_type: T,
) -> Result<(), Self::Error>;
fn pin(&self, id: F) -> Result<(), Self::Error>;
fn unpin(&self, id: F) -> Result<(), Self::Error>;
fn remove(&self, id: F) -> Result<(), Self::Error>;
fn capacity(&self) -> usize;
fn size(&self) -> usize;
}Expand description
Page eviction policy.
Defines an interface for interacting with different page replacement strategies. At its core, it provides methods for logging data access, managing meta-data, and eventually locating the next frame to evict.
Required Associated Types§
Required Methods§
Sourcefn evict(&self) -> Option<F>
fn evict(&self) -> Option<F>
Find the next frame to be evicted and evict it.
Only non-pinned frames are candidates for eviction.
Use EvictionPolicy::pin to pin frames.
By default, all pages are pinned and it is the responsibility of the clients to unpin them before the eviction policy implementer can start evicting them.
Successful eviction of a frame decreases the list size of non-pinned frames and potentially cleans the frame’s access history.
Sourcefn peek(&self) -> Option<F>
fn peek(&self) -> Option<F>
Peek into the next frame to be evicted.
This function does not remove the frame from the list of non-pinned frames.
Sourcefn touch(&self, id: F) -> Result<(), Self::Error>
fn touch(&self, id: F) -> Result<(), Self::Error>
Notifies the policy manager that a page controlled by the frame has been referenced/accessed.
This normally updates the access history of a frame using the current timestamp.
Sourcefn touch_with<T: AccessType>(
&self,
id: F,
access_type: T,
) -> Result<(), Self::Error>
fn touch_with<T: AccessType>( &self, id: F, access_type: T, ) -> Result<(), Self::Error>
Notifies the policy manager that a page controlled by the frame has been referenced/accessed. In addition to mere occurrence of access, this method also logs the type of the access.
Sourcefn pin(&self, id: F) -> Result<(), Self::Error>
fn pin(&self, id: F) -> Result<(), Self::Error>
Pin a frame, marking it as non-evictable.
If the frame is already pinned, nothing happens.
Sourcefn unpin(&self, id: F) -> Result<(), Self::Error>
fn unpin(&self, id: F) -> Result<(), Self::Error>
Unpin a frame, marking it as evictable.
If the frame is already unpinned, nothing happens.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.