pub type SharedEpochChanges<Block, Epoch> = SharedData<EpochChangesFor<Block, Epoch>>;
Expand description
A shared epoch changes tree.
Aliased Type§
struct SharedEpochChanges<Block, Epoch> { /* private fields */ }
Implementations
pub fn new(shared_data: T) -> SharedData<T>
pub fn new(shared_data: T) -> SharedData<T>
Create a new instance of [SharedData
] to share the given shared_data
.
Acquire access to the shared data.
This will give mutable access to the shared data. After the returned mutex guard is dropped, the shared data is accessible by other threads. So, this function should be used when reading/writing of the shared data in a local context is required.
When requiring to lock shared data for some longer time, even with temporarily releasing the
lock, [Self::shared_data_locked
] should be used.
Acquire access to the shared data and lock it.
This will give mutable access to the shared data. The returned [SharedDataLocked
]
provides the function [SharedDataLocked::release_mutex
] to release the mutex, but
keeping the data locked. This is useful in async contexts for example where the data needs
to be locked, but a mutex guard can not be held.
For an example see [SharedData
].