mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-22 21:05:11 +00:00
add report_untracked_read to salsa::Database
This commit is contained in:
parent
e86252d051
commit
8e754ec0d7
3 changed files with 11 additions and 4 deletions
|
@ -22,6 +22,14 @@ pub trait Database: HasJarsDyn + AsSalsaDatabase {
|
||||||
fn synthetic_write(&mut self, durability: Durability) {
|
fn synthetic_write(&mut self, durability: Durability) {
|
||||||
self.runtime_mut().synthetic_write(durability);
|
self.runtime_mut().synthetic_write(durability);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Reports that the query depends on some state unknown to salsa.
|
||||||
|
///
|
||||||
|
/// Queries which report untracked reads will be re-executed in the next
|
||||||
|
/// revision.
|
||||||
|
fn report_untracked_read(&self) {
|
||||||
|
self.runtime().report_untracked_read();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Indicates a database that also supports parallel query
|
/// Indicates a database that also supports parallel query
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
use std::panic::{RefUnwindSafe, UnwindSafe};
|
use std::panic::{RefUnwindSafe, UnwindSafe};
|
||||||
|
|
||||||
use expect_test::expect;
|
use expect_test::expect;
|
||||||
use salsa::storage::HasJarsDyn;
|
|
||||||
use salsa::Durability;
|
use salsa::Durability;
|
||||||
|
|
||||||
// Axes:
|
// Axes:
|
||||||
|
@ -99,13 +98,13 @@ fn memoized_b(db: &dyn Db, input: MyInput) {
|
||||||
|
|
||||||
#[salsa::tracked(jar = Jar)]
|
#[salsa::tracked(jar = Jar)]
|
||||||
fn volatile_a(db: &dyn Db, input: MyInput) {
|
fn volatile_a(db: &dyn Db, input: MyInput) {
|
||||||
db.runtime().report_untracked_read();
|
db.report_untracked_read();
|
||||||
volatile_b(db, input)
|
volatile_b(db, input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[salsa::tracked(jar = Jar)]
|
#[salsa::tracked(jar = Jar)]
|
||||||
fn volatile_b(db: &dyn Db, input: MyInput) {
|
fn volatile_b(db: &dyn Db, input: MyInput) {
|
||||||
db.runtime().report_untracked_read();
|
db.report_untracked_read();
|
||||||
volatile_a(db, input)
|
volatile_a(db, input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ fn get_hot_potato2(db: &dyn Db, input: MyInput) -> u32 {
|
||||||
#[salsa::tracked(jar = Jar, lru = 32)]
|
#[salsa::tracked(jar = Jar, lru = 32)]
|
||||||
fn get_volatile(db: &dyn Db, _input: MyInput) -> usize {
|
fn get_volatile(db: &dyn Db, _input: MyInput) -> usize {
|
||||||
static COUNTER: AtomicUsize = AtomicUsize::new(0);
|
static COUNTER: AtomicUsize = AtomicUsize::new(0);
|
||||||
db.runtime().report_untracked_read();
|
db.report_untracked_read();
|
||||||
COUNTER.fetch_add(1, Ordering::SeqCst)
|
COUNTER.fetch_add(1, Ordering::SeqCst)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue