pub struct GuestMemoryAtomic<M: GuestMemory> { /* private fields */ }
Expand description

A fast implementation of a mutable collection of memory regions.

This implementation uses ArcSwap to provide RCU-like snapshotting of the memory map: every update of the memory map creates a completely new GuestMemory object, and readers will not be blocked because the copies they retrieved will be collected once no one can access them anymore. Under the assumption that updates to the memory map are rare, this allows a very efficient implementation of the memory() method.

Implementations§

source§

impl<M: GuestMemory> GuestMemoryAtomic<M>

source

pub fn new(map: M) -> Self

create a new GuestMemoryAtomic object whose initial contents come from the map GuestMemory.

source

pub fn lock(&self) -> LockResult<GuestMemoryExclusiveGuard<'_, M>>

Acquires the update mutex for the GuestMemoryAtomic, blocking the current thread until it is able to do so. The returned RAII guard allows for scoped unlock of the mutex (that is, the mutex will be unlocked when the guard goes out of scope), and optionally also for replacing the contents of the GuestMemoryAtomic when the lock is dropped.

Trait Implementations§

source§

impl<M: Clone + GuestMemory> Clone for GuestMemoryAtomic<M>

source§

fn clone(&self) -> GuestMemoryAtomic<M>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<M: Debug + GuestMemory> Debug for GuestMemoryAtomic<M>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<M: GuestMemory> From<Arc<M>> for GuestMemoryAtomic<M>

source§

fn from(map: Arc<M>) -> Self

create a new GuestMemoryAtomic object whose initial contents come from the map reference counted GuestMemory.

source§

impl<M: GuestMemory> GuestAddressSpace for GuestMemoryAtomic<M>

§

type T = GuestMemoryLoadGuard<M>

A type that provides access to the memory.
§

type M = M

The type that will be used to access guest memory.
source§

fn memory(&self) -> Self::T

Return an object (e.g. a reference or guard) that can be used to access memory through this address space. The object provides a consistent snapshot of the memory map.

Auto Trait Implementations§

§

impl<M> RefUnwindSafe for GuestMemoryAtomic<M>
where M: RefUnwindSafe,

§

impl<M> Send for GuestMemoryAtomic<M>
where M: Send + Sync,

§

impl<M> Sync for GuestMemoryAtomic<M>
where M: Send + Sync,

§

impl<M> Unpin for GuestMemoryAtomic<M>

§

impl<M> UnwindSafe for GuestMemoryAtomic<M>
where M: RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.