Skip to main content

SeqLock

Struct SeqLock 

Source
pub struct SeqLock<H: IntoBytes + Immutable, T: IntoBytes + Immutable> { /* private fields */ }
Expand description

Declare an instance of SeqLock by supplying header([H]) and value([T]) types, which should be configured with C-style layout & alignment. SeqLock will place a 32-bit atomic sequence number in-between the header and value, in a VMO.

Implementations§

Source§

impl<H: IntoBytes + Default + Immutable, T: IntoBytes + Default + Immutable> SeqLock<H, T>

Source

pub fn new_default() -> Result<Self, Status>

Source§

impl<H: IntoBytes + Immutable, T: IntoBytes + Immutable> SeqLock<H, T>

Source

pub fn new(header: H, value: T) -> Result<Self, Status>

Returns an instance with initial values and a read-only VMO handle. May fail if the VMO backing the structure cannot be created, duplicated read-only, or mapped.

Source

pub unsafe fn new_from_vmo( header: H, value: T, writable_vmo: Vmo, ) -> Result<Self, Status>

Same as new() except that we can pass in an existing Vmo. This means that the first part of the Vmo is a SeqLock.

§Safety

Callers must guarantee that any other references to this memory will only make aligned atomic accesses to the sequence offset within the memory or to fields of H or T.

Source

pub fn get_readonly_vmo(&self) -> Arc<Vmo>

Returns a read-only handle to the VMO containing the header, atomic sequence number, and value.

Source

pub fn set_value(&self, value: T)

Updates the value directly. Uses Seqlock pattern.

Source

pub fn get_map_address(&mut self) -> *const T

Retrieves the memory address of the beginning of the handle part of the VMO. You can use this to point to a param you want to edit (e.g. with an offset).

Trait Implementations§

Source§

impl<H: IntoBytes + Immutable, T: IntoBytes + Immutable> Drop for SeqLock<H, T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<H, T> Freeze for SeqLock<H, T>

§

impl<H, T> RefUnwindSafe for SeqLock<H, T>

§

impl<H, T> Send for SeqLock<H, T>
where H: Send, T: Send,

§

impl<H, T> Sync for SeqLock<H, T>
where H: Sync, T: Sync,

§

impl<H, T> Unpin for SeqLock<H, T>
where H: Unpin, T: Unpin,

§

impl<H, T> UnsafeUnpin for SeqLock<H, T>

§

impl<H, T> UnwindSafe for SeqLock<H, T>
where H: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AsAny for T
where T: Any,

§

fn as_any(&self) -> &(dyn Any + 'static)

§

fn type_name(&self) -> &'static str

Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
§

impl<T, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T, U> Into32<U> for T
where U: MultiArchFrom<T>,

§

fn into_32(self) -> U

§

impl<T, U> Into64<U> for T
where U: MultiArchFrom<T>,

§

fn into_64(self) -> U

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

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

§

fn from_64(value: T) -> U

§

fn from_32(value: T) -> U

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<B, A> LockBefore<B> for A
where B: LockAfter<A>,

§

impl<B, A> LockEqualOrBefore<B> for A
where A: LockBefore<B>,