Skip to main content

LazyConfig

Struct LazyConfig 

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

Implementations§

Source§

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

Source

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

Source

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

Source

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

Fast path: returns the value when loaded, otherwise None.

Source

pub fn is_loaded(&self) -> bool

True when the config has been loaded.

Source

pub fn get_or_fetch<F: FnOnce() -> T>(&self, fetcher: F) -> T

Get the value if cached. Otherwise, race to be the canonical fetcher: the CAS winner runs fetcher and publishes; CAS losers block until the winner publishes, then return the canonical value.

Across all processes mapping this file, fetcher runs at most once per process AND only one process’s result becomes canonical. (In practice with the CAS-then-fetch protocol from SharedOnceCell::get_or_init, the winner is the only one to actually run the fetcher.)

Source

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

Force-set the value without going through a fetcher. Useful for testing or for an admin-set-config workflow. Returns true if this caller’s value became canonical (it won the CAS), false when the cell was already initialised.

Source

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

Source

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

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

§

impl<T> !Freeze for LazyConfig<T>

§

impl<T> !UnwindSafe for LazyConfig<T>

§

impl<T> RefUnwindSafe for LazyConfig<T>

§

impl<T> Send for LazyConfig<T>
where Arc<SharedOnceCell<T>>: Send,

§

impl<T> Sync for LazyConfig<T>
where Arc<SharedOnceCell<T>>: Sync,

§

impl<T> Unpin for LazyConfig<T>

§

impl<T> UnsafeUnpin for LazyConfig<T>

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.