Skip to main content

GlobalSnapshot

Struct GlobalSnapshot 

Source
pub struct GlobalSnapshot { /* private fields */ }
Expand description

The global mutable snapshot.

This is a special singleton snapshot that represents the global state. All non-nested snapshots implicitly depend on the global snapshot.

§Thread Safety

Contains Cell<T> which is not Send/Sync. This is safe because snapshots are stored in thread-local storage and never shared across threads. The Arc is used for cheap cloning within a single thread, not for cross-thread sharing.

Implementations§

Source§

impl GlobalSnapshot

Source

pub fn new(id: SnapshotId, invalid: SnapshotIdSet) -> Arc<Self>

Create a new global snapshot.

The global snapshot does NOT pin because it always represents the current state and reads the latest records. Pinning would prevent garbage collection.

Source

pub fn get_or_create() -> Arc<Self>

Get or create the global snapshot instance.

Source

pub fn advance(&self, new_id: SnapshotId)

Advance the global snapshot to a new ID.

Source§

impl GlobalSnapshot

Source

pub fn snapshot_id(&self) -> SnapshotId

Source

pub fn invalid(&self) -> SnapshotIdSet

Source

pub fn read_only(&self) -> bool

Source

pub fn root_global(&self) -> Arc<Self>

Source

pub fn enter<T>(&self, f: impl FnOnce() -> T) -> T

Source

pub fn take_nested_snapshot( &self, read_observer: Option<ReadObserver>, ) -> Arc<ReadonlySnapshot>

Source

pub fn has_pending_changes(&self) -> bool

Source

pub fn pending_children(&self) -> Vec<SnapshotId>

Source

pub fn has_pending_children(&self) -> bool

Source

pub fn dispose(&self)

Source

pub fn record_read(&self, state: &dyn StateObject)

Source

pub fn record_write(&self, state: Arc<dyn StateObject>)

Source

pub fn close(&self)

Source

pub fn is_disposed(&self) -> bool

Source

pub fn apply(&self) -> SnapshotApplyResult

Source

pub fn take_nested_mutable_snapshot( &self, read_observer: Option<ReadObserver>, write_observer: Option<WriteObserver>, ) -> Arc<MutableSnapshot>

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.