pub struct Runtime<DB: Database> { /* private fields */ }
Expand description
The salsa runtime stores the storage for all queries as well as tracking the query stack and dependencies between cycles.
Each new runtime you create (e.g., via Runtime::new
or
Runtime::default
) will have an independent set of query storage
associated with it. Normally, therefore, you only do this once, at
the start of your application.
Implementations
sourceimpl<DB> Runtime<DB>where
DB: Database,
impl<DB> Runtime<DB>where
DB: Database,
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new runtime; equivalent to Self::default
. This is
used when creating a new database.
sourcepub fn storage(&self) -> &DB::DatabaseStorage
pub fn storage(&self) -> &DB::DatabaseStorage
Returns the underlying storage, where the keys/values for all queries are kept.
sourcepub fn snapshot(&self, from_db: &DB) -> Self
pub fn snapshot(&self, from_db: &DB) -> Self
Returns a “forked” runtime, suitable for use in a forked
database. “Forked” runtimes hold a read-lock on the global
state, which means that any attempt to set
an input will
block until the forked runtime is dropped. See
ParallelDatabase::snapshot
for more information.
Warning. This second handle is intended to be used from a separate thread. Using two database handles from the same thread can lead to deadlock.
sourcepub fn next_revision(&self)
pub fn next_revision(&self)
Indicates that some input to the system has changed and hence that memoized values may be invalidated. This cannot be invoked while query computation is in progress.
As a user of the system, you would not normally invoke this
method directly. Instead, you would use “input” queries and
invoke their set
method. But it can be useful if you have a
“volatile” input that you must poll from time to time; in that
case, you can wrap the input with a “no-storage” query and
invoke this method from time to time.
sourcepub fn sweep_all(&self, db: &DB, strategy: SweepStrategy)
pub fn sweep_all(&self, db: &DB, strategy: SweepStrategy)
Default implementation for Database::sweep_all
.
sourcepub fn id(&self) -> RuntimeId
pub fn id(&self) -> RuntimeId
The unique identifier attached to this SalsaRuntime
. Each
snapshotted runtime has a distinct identifier.
sourcepub fn active_query(&self) -> Option<DB::QueryDescriptor>
pub fn active_query(&self) -> Option<DB::QueryDescriptor>
Returns the descriptor for the query that this thread is actively executing (if any).
sourcepub fn is_current_revision_canceled(&self) -> bool
pub fn is_current_revision_canceled(&self) -> bool
Check if the current revision is canceled. If this method ever returns true, the currently executing query is also marked as having an untracked read – this means that, in the next revision, we will always recompute its value “as if” some input had changed. This means that, if your revision is canceled (which indicates that current query results will be ignored) your query is free to shortcircuit and return whatever it likes.