mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-23 13:10:19 +00:00
2d2bdfe7f1
They aren't meant to be things to model oneself after.
31 lines
753 B
Rust
31 lines
753 B
Rust
use crate::queries;
|
|
use std::cell::Cell;
|
|
|
|
#[derive(Default)]
|
|
pub struct QueryContextImpl {
|
|
runtime: salsa::runtime::Runtime<QueryContextImpl>,
|
|
counter: Cell<usize>,
|
|
}
|
|
|
|
salsa::query_context_storage! {
|
|
pub struct QueryContextImplStorage for QueryContextImpl {
|
|
impl queries::QueryContext {
|
|
fn memoized() for queries::Memoized;
|
|
fn volatile() for queries::Volatile;
|
|
}
|
|
}
|
|
}
|
|
|
|
impl queries::CounterContext for QueryContextImpl {
|
|
fn increment(&self) -> usize {
|
|
let v = self.counter.get();
|
|
self.counter.set(v + 1);
|
|
v
|
|
}
|
|
}
|
|
|
|
impl salsa::QueryContext for QueryContextImpl {
|
|
fn salsa_runtime(&self) -> &salsa::runtime::Runtime<QueryContextImpl> {
|
|
&self.runtime
|
|
}
|
|
}
|