pub struct SeqLockPayload<T: Copy + FromBytes + IntoBytes + Immutable, const LOCK_SYNC_OPT: u8 = SYNC_OPT_FENCE> { /* private fields */ }Expand description
Payload wrapper for data protected by a SeqLock.
SeqLockPayload<T, LOCK_SYNC_OPT> wraps a WellDefinedCopyable<T> and
binds its synchronization mode (COPY_SYNC_OPT) to that required by
SeqLock<LOCK_SYNC_OPT>.
Implementations§
Source§impl<T: Copy + FromBytes + IntoBytes + Immutable, const LOCK_SYNC_OPT: u8> SeqLockPayload<T, LOCK_SYNC_OPT>
impl<T: Copy + FromBytes + IntoBytes + Immutable, const LOCK_SYNC_OPT: u8> SeqLockPayload<T, LOCK_SYNC_OPT>
Sourcepub const COPY_SYNC_OPT: SyncOpt = SeqLock<LOCK_SYNC_OPT>::COPY_WRAPPER_SYNC_OPT
pub const COPY_SYNC_OPT: SyncOpt = SeqLock<LOCK_SYNC_OPT>::COPY_WRAPPER_SYNC_OPT
The sync options we use for this payload are specified for us based on the lock type we plan to use this payload with.
Sourcepub fn read(&self, dst: &mut T)
pub fn read(&self, dst: &mut T)
Specific version of read which always uses the sync-opt dictated to
us by our associated lock type.
Sourcepub fn update(&self, _guard: &WriteGuard<'_, LOCK_SYNC_OPT>, src: &T)
pub fn update(&self, _guard: &WriteGuard<'_, LOCK_SYNC_OPT>, src: &T)
Specific version of update which always uses the sync-opt dictated to
us by our associated lock type.
Sourcepub fn begin_in_place_update(
&self,
_guard: &WriteGuard<'_, LOCK_SYNC_OPT>,
) -> *mut T
pub fn begin_in_place_update( &self, _guard: &WriteGuard<'_, LOCK_SYNC_OPT>, ) -> *mut T
Gain R/W access to the payload in order to perform an in-place update of the contents using fence-to-fence synchronization to protect the payload. All stores to the payload accessed via this pointer should be done using relaxed atomic stores.
Sourcepub const fn unsynchronized_get(
&self,
_guard: &WriteGuard<'_, LOCK_SYNC_OPT>,
) -> *const T
pub const fn unsynchronized_get( &self, _guard: &WriteGuard<'_, LOCK_SYNC_OPT>, ) -> *const T
Exposes WellDefinedCopyable::unsynchronized_get for this payload.
Dereferencing the returned pointer is only safe if _guard belongs to the
SeqLock protecting this payload so that no concurrent writes can occur
while reading the instance.