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
impl GlobalSnapshot
Sourcepub fn new(id: SnapshotId, invalid: SnapshotIdSet) -> Arc<Self> ⓘ
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.
Sourcepub fn get_or_create() -> Arc<Self> ⓘ
pub fn get_or_create() -> Arc<Self> ⓘ
Get or create the global snapshot instance.
Sourcepub fn advance(&self, new_id: SnapshotId)
pub fn advance(&self, new_id: SnapshotId)
Advance the global snapshot to a new ID.
Source§impl GlobalSnapshot
impl GlobalSnapshot
pub fn snapshot_id(&self) -> SnapshotId
pub fn invalid(&self) -> SnapshotIdSet
pub fn read_only(&self) -> bool
pub fn root_global(&self) -> Arc<Self> ⓘ
pub fn enter<T>(&self, f: impl FnOnce() -> T) -> T
pub fn take_nested_snapshot( &self, read_observer: Option<ReadObserver>, ) -> Arc<ReadonlySnapshot> ⓘ
pub fn has_pending_changes(&self) -> bool
pub fn pending_children(&self) -> Vec<SnapshotId> ⓘ
pub fn has_pending_children(&self) -> bool
pub fn dispose(&self)
pub fn record_read(&self, state: &dyn StateObject)
pub fn record_write(&self, state: Arc<dyn StateObject>)
pub fn close(&self)
pub fn is_disposed(&self) -> bool
pub fn apply(&self) -> SnapshotApplyResult
pub fn take_nested_mutable_snapshot( &self, read_observer: Option<ReadObserver>, write_observer: Option<WriteObserver>, ) -> Arc<MutableSnapshot> ⓘ
Auto Trait Implementations§
impl !Freeze for GlobalSnapshot
impl !RefUnwindSafe for GlobalSnapshot
impl !Send for GlobalSnapshot
impl !Sync for GlobalSnapshot
impl !UnwindSafe for GlobalSnapshot
impl Unpin for GlobalSnapshot
impl UnsafeUnpin for GlobalSnapshot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more