Struct kdevice::cache::CacheEntry[][src]

pub struct CacheEntry<'a, T: Cache> { /* fields omitted */ }
Expand description

Representing a client of a cache entry.

There may be several CacheEntry that refer to the same cache entry (i.e. same key) at a time. Therefore, Cache maintains reference counter for each in-memory cache entry. If the reference couter is not zero, it cannot be replace by another cache entyr. Once the the counter decreases to zero, it will be moved to the back of LRU and can be flushed to disk when replaced by another cache entry.

Implementations

impl<'a, T: Cache> CacheEntry<'a, T>[src]

pub async fn lock(&'a self) -> Result<CacheGuard<'a, T>>[src]

Lock and read the cache entry.

pub fn leak(self) -> CacheNodePtr<T::Key, T::Value>[src]

Get pointer to this cache entry.

pub fn key(&self) -> T::Key[src]

Get the key of this cache entry.

Safe since the key is immutable since referenced.

pub fn nref(&self) -> usize[src]

Get the reference count of this cache entry.

Note that the count may changes after this function returns. You may need to lock the whole cache to make sure it is the latest ref count.

pub unsafe fn from_ptr(
    cache: &'a T,
    ptr: CacheNodePtr<T::Key, T::Value>
) -> Self
[src]

Restore the cache entry from a node pointer. Useful for non-RAII operations.

Trait Implementations

impl<'a, T: Cache> Drop for CacheEntry<'a, T>[src]

fn drop(&mut self)[src]

Executes the destructor for this type. Read more

Auto Trait Implementations

impl<'a, T> !RefUnwindSafe for CacheEntry<'a, T>

impl<'a, T> Send for CacheEntry<'a, T> where
    T: Sync,
    <T as Cache>::Key: Send,
    <T as Cache>::Value: Send

impl<'a, T> Sync for CacheEntry<'a, T> where
    T: Sync,
    <T as Cache>::Key: Sync,
    <T as Cache>::Value: Sync

impl<'a, T> Unpin for CacheEntry<'a, T>

impl<'a, T> !UnwindSafe for CacheEntry<'a, T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.