Struct vm_memory::atomic::GuestMemoryAtomic
source · [−]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
sourceimpl<M: GuestMemory> GuestMemoryAtomic<M>
impl<M: GuestMemory> GuestMemoryAtomic<M>
sourcepub fn new(map: M) -> Self
pub fn new(map: M) -> Self
create a new GuestMemoryAtomic
object whose initial contents come from
the map
GuestMemory
.
sourcepub fn lock(&self) -> LockResult<GuestMemoryExclusiveGuard<'_, M>>
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
sourceimpl<M: Clone + GuestMemory> Clone for GuestMemoryAtomic<M>
impl<M: Clone + GuestMemory> Clone for GuestMemoryAtomic<M>
sourcefn clone(&self) -> GuestMemoryAtomic<M>
fn clone(&self) -> GuestMemoryAtomic<M>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<M: Debug + GuestMemory> Debug for GuestMemoryAtomic<M>
impl<M: Debug + GuestMemory> Debug for GuestMemoryAtomic<M>
sourceimpl<M: GuestMemory> From<Arc<M>> for GuestMemoryAtomic<M>
impl<M: GuestMemory> From<Arc<M>> for GuestMemoryAtomic<M>
sourceimpl<M: GuestMemory> GuestAddressSpace for GuestMemoryAtomic<M>
impl<M: GuestMemory> GuestAddressSpace for GuestMemoryAtomic<M>
type T = GuestMemoryLoadGuard<M>
type T = GuestMemoryLoadGuard<M>
A type that provides access to the memory.
type M = M
type M = M
The type that will be used to access guest memory.
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more