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,
pub fn new() -> Self
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 fork(&self) -> Self
pub fn fork(&self) -> Self
As with Database::fork
, creates a second copy of the runtime
meant to be used from another thread.
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 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.