referrerpolicy=no-referrer-when-downgrade
sc_consensus_epochs

Type Alias SharedEpochChanges

Source
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

§

impl<T> SharedData<T>

pub fn new(shared_data: T) -> SharedData<T>

Create a new instance of [SharedData] to share the given shared_data.

pub fn shared_data(&self) -> MappedMutexGuard<'_, RawMutex, T>

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.

pub fn shared_data_locked(&self) -> SharedDataLocked<'_, T>

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].

Trait Implementations

§

impl<T> Clone for SharedData<T>

§

fn clone(&self) -> SharedData<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more