Skip to main content

SharedAsyncPointer

Struct SharedAsyncPointer 

Source
pub struct SharedAsyncPointer<T: Copy + Send + Sync + 'static> { /* private fields */ }

Implementations§

Source§

impl<T: Copy + Send + Sync + 'static> SharedAsyncPointer<T>

Source

pub const SIGNATURE: AxisMask

Direction signature of SharedAsyncPointer<T>. Engages the K_async axis (future / async-state stored at slot for cross-process await on a value that may not yet exist).

Source

pub fn create(path: impl AsRef<Path>) -> Result<Self, SharedAsyncError>

Create a new shared async pointer backed by an MMF cell at path. The cell starts EMPTY.

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self, SharedAsyncError>

Open an existing shared async pointer.

Source

pub fn is_resolved(&self) -> bool

True when the underlying cell is initialised.

Source

pub fn try_get(&self) -> Option<T>

Non-blocking peek. Returns the canonical value if any.

Source

pub fn set_resolved(&self, value: T) -> bool

Pre-resolve by setting the value. Returns true if this caller won the init race, false if the cell was already initialised.

Source

pub fn get_or_lazy<F>(&self, f: F) -> T
where F: FnOnce() -> T,

Lazy resolution: if the cell is initialised, return its value. Otherwise, the caller runs f once and attempts to publish the result. If another concurrent caller wins the publish race, the caller still returns the canonical value (theirs may be discarded silently).

Source

pub fn get_or_speculative<F>(&self, n: usize, f: F) -> T
where F: Fn() -> T + Send + Sync + 'static + Clone,

Speculative resolution: spawn n worker threads that all independently compute f() and race to publish the result. First publisher wins; losers discard their results. Returns the canonical value (the winner’s).

All N workers share the same f (closure must be Clone + Send + Sync). Use get_or_speculative_with when each worker needs a different closure (e.g., different backends).

Source

pub fn get_or_speculative_with<I, F>(&self, fs: I) -> T
where I: IntoIterator<Item = F>, F: FnOnce() -> T + Send + 'static,

Speculative resolution with per-worker closures. Each closure in fs is dispatched to one worker; first publisher wins.

Source

pub fn get_or_speculative_resilient<F>( &self, n: usize, f: F, ) -> Result<T, SharedAsyncError>
where F: Fn() -> T + Send + Sync + 'static + Clone,

Speculative resolution that tolerates worker panics: closures that panic do not propagate; the race continues among survivors. Returns Err(AllWorkersDied) if every worker panicked AND no value was published.

Source

pub fn flush(&self) -> Result<(), SharedAsyncError>

Sync the underlying cell to disk.

Source

pub fn flush_async(&self) -> Result<(), SharedAsyncError>

Non-blocking flush: schedules a writeback via the OS. Note: Windows is only partially async (sync to page cache, not to disk).

Trait Implementations§

Source§

impl<T: Copy + Send + Sync + 'static> AdaptiveInstance for SharedAsyncPointer<T>

Source§

fn header(&self) -> &HandshakeHeader

Source§

fn ring(&self) -> &ObservationRing

Source§

fn make_policy(&self) -> Box<dyn Policy>

Source§

fn apply_migration(&self, new_tag: u32)

Called by the sidecar when the policy returns a new strategy tag. Default implementation: just set the tag on the header. Primitives that need heavier migration (data-layout swap) override this to perform the swap before (or after) updating the tag.

Auto Trait Implementations§

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

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.