pub struct SharedAsyncPointer<T: Copy + Send + Sync + 'static> { /* private fields */ }Implementations§
Sourcepub const SIGNATURE: AxisMask
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).
Sourcepub fn create(path: impl AsRef<Path>) -> Result<Self, SharedAsyncError>
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.
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self, SharedAsyncError>
pub fn open(path: impl AsRef<Path>) -> Result<Self, SharedAsyncError>
Open an existing shared async pointer.
Sourcepub fn is_resolved(&self) -> bool
pub fn is_resolved(&self) -> bool
True when the underlying cell is initialised.
Sourcepub fn set_resolved(&self, value: T) -> bool
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.
Sourcepub fn get_or_lazy<F>(&self, f: F) -> Twhere
F: FnOnce() -> T,
pub fn get_or_lazy<F>(&self, f: F) -> Twhere
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).
Sourcepub fn get_or_speculative<F>(&self, n: usize, f: F) -> T
pub fn get_or_speculative<F>(&self, n: usize, f: F) -> T
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).
Sourcepub fn get_or_speculative_with<I, F>(&self, fs: I) -> T
pub fn get_or_speculative_with<I, F>(&self, fs: I) -> T
Speculative resolution with per-worker closures. Each closure
in fs is dispatched to one worker; first publisher wins.
Sourcepub fn get_or_speculative_resilient<F>(
&self,
n: usize,
f: F,
) -> Result<T, SharedAsyncError>
pub fn get_or_speculative_resilient<F>( &self, n: usize, f: F, ) -> Result<T, SharedAsyncError>
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.
Sourcepub fn flush(&self) -> Result<(), SharedAsyncError>
pub fn flush(&self) -> Result<(), SharedAsyncError>
Sync the underlying cell to disk.
Sourcepub fn flush_async(&self) -> Result<(), SharedAsyncError>
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).