Skip to main content

SyncOpt

Enum SyncOpt 

Source
#[repr(u8)]
pub enum SyncOpt { AcqRelOps = 0, Fence = 1, None = 2, }
Expand description

An enumeration of various synchronization options to use when performing memory transfer operations with well_defined_copy_to / well_defined_copy_from.

§AcqRelOps

Use either Ordering::Acquire (CopyFrom) or Ordering::Release (CopyTo) on every atomic load/store operation during the transfer to/from the shared buffer.

§Fence

Use either an Ordering::Acquire thread fence (CopyFrom) after the transfer operation, or an Ordering::Release (CopyTo) thread fence before the operation, and Ordering::Relaxed for each of the atomic load/store operations during the transfer.

§None

Simply use Ordering::Relaxed for each of the atomic load/store operations during the transfer. Do not actually introduce any explicit synchronization behavior.

WARNING: Use cases for this transfer mode tend to be unusual. Users will almost always want some form of synchronization to take place during their transfers. One example of where it may be appropriate to use SyncOpt::None might be a situation where users are attempting to observe the state of more than one object while inside of a sequence lock read transaction, and the user has decided that it is better to use a thread fence than to use acquire semantics on each element transferred. Such a sequence might look something like this:

let mut foo1 = Foo::default();
let mut foo2 = Foo::default();
let mut bar1 = Bar::default();
let mut bar2 = Bar::default();
// ...
src_foo1.read::<SYNC_OPT_NONE>(&mut foo1);
src_foo2.read::<SYNC_OPT_NONE>(&mut foo2);
src_bar1.read::<SYNC_OPT_NONE>(&mut bar1);
src_bar2.read::<SYNC_OPT_FENCE>(&mut bar2);

Note that it is the last transfer operation which includes the fence. In the case of a CopyTo operation (when publishing data) it would be the first operation which included the fence, not the last.

Variants§

§

AcqRelOps = 0

§

Fence = 1

§

None = 2

Implementations§

Source§

impl SyncOpt

Source

pub const fn from_u8(val: u8) -> Self

Trait Implementations§

Source§

impl Clone for SyncOpt

Source§

fn clone(&self) -> SyncOpt

Returns a duplicate of the value. Read more
1.0.0 (const: unstable)§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for SyncOpt

Source§

impl Debug for SyncOpt

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for SyncOpt

Source§

impl PartialEq for SyncOpt

Source§

fn eq(&self, other: &SyncOpt) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable)§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SyncOpt

Auto Trait Implementations§

§

impl Freeze for SyncOpt

§

impl RefUnwindSafe for SyncOpt

§

impl Send for SyncOpt

§

impl Sync for SyncOpt

§

impl Unpin for SyncOpt

§

impl UnsafeUnpin for SyncOpt

§

impl UnwindSafe for SyncOpt

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> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.