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§
source§impl<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§
source§impl<M: Clone + GuestMemory> Clone for GuestMemoryAtomic<M>
impl<M: Clone + GuestMemory> Clone for GuestMemoryAtomic<M>
source§fn clone(&self) -> GuestMemoryAtomic<M>
fn clone(&self) -> GuestMemoryAtomic<M>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more