2018-09-29 08:50:08 +00:00
|
|
|
use crate::queries;
|
|
|
|
use std::cell::Cell;
|
|
|
|
|
|
|
|
#[derive(Default)]
|
2018-10-05 08:54:51 +00:00
|
|
|
pub struct DatabaseImpl {
|
2018-10-07 11:08:22 +00:00
|
|
|
runtime: salsa::Runtime<DatabaseImpl>,
|
2018-09-29 08:50:08 +00:00
|
|
|
counter: Cell<usize>,
|
|
|
|
}
|
|
|
|
|
2018-10-05 08:54:51 +00:00
|
|
|
salsa::database_storage! {
|
|
|
|
pub struct DatabaseImplStorage for DatabaseImpl {
|
|
|
|
impl queries::Database {
|
2018-09-29 08:50:08 +00:00
|
|
|
fn memoized() for queries::Memoized;
|
2018-09-30 10:05:42 +00:00
|
|
|
fn volatile() for queries::Volatile;
|
2018-09-29 08:50:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-05 08:54:51 +00:00
|
|
|
impl queries::Counter for DatabaseImpl {
|
2018-09-29 08:50:08 +00:00
|
|
|
fn increment(&self) -> usize {
|
|
|
|
let v = self.counter.get();
|
|
|
|
self.counter.set(v + 1);
|
|
|
|
v
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-05 08:54:51 +00:00
|
|
|
impl salsa::Database for DatabaseImpl {
|
2018-10-07 11:08:22 +00:00
|
|
|
fn salsa_runtime(&self) -> &salsa::Runtime<DatabaseImpl> {
|
2018-09-29 09:31:26 +00:00
|
|
|
&self.runtime
|
2018-09-29 08:50:08 +00:00
|
|
|
}
|
|
|
|
}
|