pub struct SharedMemory {
memory: VMSharedMemory,
ops: Option<Arc<dyn SharedMemoryOps + Send + Sync>>,
}Expand description
A shared memory instance that can be shared across multiple stores and threads, not attached to any specific store.
Fields§
§memory: VMSharedMemory§ops: Option<Arc<dyn SharedMemoryOps + Send + Sync>>Implementations§
Sourcepub(crate) fn new(memory: VMSharedMemory) -> Self
pub(crate) fn new(memory: VMSharedMemory) -> Self
Create a new shared memory.
Sourcepub(crate) fn new_with_ops(
memory: VMSharedMemory,
ops: Arc<dyn SharedMemoryOps + Send + Sync>,
) -> Self
pub(crate) fn new_with_ops( memory: VMSharedMemory, ops: Arc<dyn SharedMemoryOps + Send + Sync>, ) -> Self
Create a new shared memory with memory operations.
Sourcepub fn attach(self, store: &mut impl AsStoreMut) -> Memory
pub fn attach(self, store: &mut impl AsStoreMut) -> Memory
Attach this shared memory to the provided store.
Sourcepub fn ops(&self) -> MemoryOps
pub fn ops(&self) -> MemoryOps
Create an operations handle that does not keep the underlying memory alive.
Sourcepub fn notify(
&self,
location: MemoryLocation,
count: u32,
) -> Result<u32, AtomicsError>
pub fn notify( &self, location: MemoryLocation, count: u32, ) -> Result<u32, AtomicsError>
Notify up to count waiters waiting for the memory location.
Sourcepub fn wait(
&self,
location: MemoryLocation,
timeout: Option<Duration>,
) -> Result<u32, AtomicsError>
pub fn wait( &self, location: MemoryLocation, timeout: Option<Duration>, ) -> Result<u32, AtomicsError>
Wait for the memory location to be notified.
Sourcepub fn disable_atomics(&self) -> Result<(), AtomicsError>
pub fn disable_atomics(&self) -> Result<(), AtomicsError>
Disable atomics for this memory.
All subsequent atomic wait calls will produce a trap.
This can be used or forced shutdown of instances that continuously try to wait on atomics.
NOTE: this operation might not be supported by all memory implementations. In that case, this function will return an error.
Sourcepub fn wake_all_atomic_waiters(&self) -> Result<(), AtomicsError>
pub fn wake_all_atomic_waiters(&self) -> Result<(), AtomicsError>
Wake up all atomic waiters.
This can be used to force-resume waiting execution.
NOTE: this operation might not be supported by all memory implementations. In that case, this function will return an error.
Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more