pub struct MutLock { /* private fields */ }Expand description
Global mutability lock for all SW-Agents
Since we can only allow one mutable agent execution at a given time, we need a mechanism to ensure that.
The MutLock ensures this on a per-agent basis. It holds RwLocks for all agents and provides threadsafe access.
The logic is similar but not identical to rusts ownership rules. While there can be only one read-write (mutable) execution,
there can be multiple read-only (immutable) executions even if there is an ongoing read-write execution !
The reason behind this is basically that read-only executions do not produce storage operations that would change the state in the database.
In the VmState, all write operations are buffered until the execution is finished. If there would be two executions in parallel,
we might end up commiting changes to a state, that has already changed under the hood - which is not what we want.
However, if there is a writer thread, the readers do not care, and also the writer does not care about the readers.
The readers will use the old state, until the new one is commited by the runtime.
Note: In contrast to [borderless_runtime::rt::contract::MutLock],
this version uses asynchronous locks for the agents, and a synchronous lock only for the access of the hashmap.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MutLock
impl !RefUnwindSafe for MutLock
impl Send for MutLock
impl Sync for MutLock
impl Unpin for MutLock
impl !UnwindSafe for MutLock
Blanket Implementations§
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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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