[−][src]Struct olio::mem::MemHandle
Wrapper over a byte buffer, supporting concurrent memory access advice, where the highest priority advice wins.
This is likely to only be useful for memory mapped regions and memory mapped files in particular.
Uses an internal Arc
over shared state, so cloning the handle is
inexpensive. Each new and cloned handle starts with the implicit
MemAdvice::Normal
. The shared state, a list of advisor interest counts,
is maintained as a single atomic integer, for minimal overhead. Each
MemAdvice
level is allocated 10-bits or up to 1,023 MemHandle
advisors. Any advice beyond this capacity or after an error is returned
from advise
, may be ignored, favoring the prior highest priority
advice.
Methods
impl<T> MemHandle<T> where
T: Deref<Target = [u8]>,
[src]
T: Deref<Target = [u8]>,
pub fn new(mem: T) -> MemHandle<T>
[src]
Wrap an owned instance of a byte slice buffer. Additional (atomic)
references to the underlying buffer can then be created by clone
of
this handle.
pub fn advise(&self, advice: MemAdvice) -> Result<MemAdvice, MemAdviseError>
[src]
Advise on access plans for the underlying memory. There may be multiple cloned handles to the same memory region, so the advice is only relayed to the operating system if it has greater priority than any other advice made via another surviving handle. On success, returns the MemAdvice as relayed, or a snapshot of the current, highest priority advice. Returns an error if the underlying system call fails.
Trait Implementations
impl<T> Clone for MemHandle<T> where
T: Deref<Target = [u8]>,
[src]
T: Deref<Target = [u8]>,
fn clone(&self) -> MemHandle<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T> Drop for MemHandle<T> where
T: Deref<Target = [u8]>,
[src]
T: Deref<Target = [u8]>,
impl<T> Deref for MemHandle<T> where
T: Deref<Target = [u8]>,
[src]
T: Deref<Target = [u8]>,
impl<T: Debug> Debug for MemHandle<T> where
T: Deref<Target = [u8]>,
[src]
T: Deref<Target = [u8]>,
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,