Skip to main content

SeqLockPayload

Struct SeqLockPayload 

Source
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>

Source

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.

Source

pub const fn new(instance: T) -> Self

Forwarding constructor for our payload.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<T: Copy + FromBytes + IntoBytes + Immutable + Default, const LOCK_SYNC_OPT: u8> Default for SeqLockPayload<T, LOCK_SYNC_OPT>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T, const LOCK_SYNC_OPT: u8 = SYNC_OPT_FENCE> !Freeze for SeqLockPayload<T, LOCK_SYNC_OPT>

§

impl<T, const LOCK_SYNC_OPT: u8 = SYNC_OPT_FENCE> !RefUnwindSafe for SeqLockPayload<T, LOCK_SYNC_OPT>

§

impl<T, const LOCK_SYNC_OPT: u8> Send for SeqLockPayload<T, LOCK_SYNC_OPT>
where T: Send,

§

impl<T, const LOCK_SYNC_OPT: u8> Sync for SeqLockPayload<T, LOCK_SYNC_OPT>
where T: Send,

§

impl<T, const LOCK_SYNC_OPT: u8> Unpin for SeqLockPayload<T, LOCK_SYNC_OPT>
where T: Unpin,

§

impl<T, const LOCK_SYNC_OPT: u8> UnsafeUnpin for SeqLockPayload<T, LOCK_SYNC_OPT>
where T: UnsafeUnpin,

§

impl<T, const LOCK_SYNC_OPT: u8> UnwindSafe for SeqLockPayload<T, LOCK_SYNC_OPT>
where T: UnwindSafe,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

Source§

impl<T> ToMutPtr for T
where T: ?Sized,

Source§

type Target = T

The target type of the pointer.
Source§

fn to_mut_ptr(&self) -> *mut T

Casts the reference to a mutable raw pointer.
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = !

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.