mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-22 21:05:11 +00:00
refactor to have a revision and shared state in runtime
Pare down our feature list to what we actually *use*
This commit is contained in:
parent
72a5b50368
commit
2e7e77516e
2 changed files with 21 additions and 7 deletions
|
@ -2,10 +2,7 @@
|
||||||
#![feature(in_band_lifetimes)]
|
#![feature(in_band_lifetimes)]
|
||||||
#![feature(crate_visibility_modifier)]
|
#![feature(crate_visibility_modifier)]
|
||||||
#![feature(nll)]
|
#![feature(nll)]
|
||||||
#![feature(min_const_fn)]
|
#![feature(integer_atomics)]
|
||||||
#![feature(const_fn)]
|
|
||||||
#![feature(const_let)]
|
|
||||||
#![feature(try_from)]
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![allow(unused_imports)]
|
#![allow(unused_imports)]
|
||||||
|
|
||||||
|
|
|
@ -2,23 +2,40 @@ use crate::Query;
|
||||||
use crate::QueryContext;
|
use crate::QueryContext;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
|
use std::sync::atomic::AtomicU64;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct Runtime<QC>
|
pub struct Runtime<QC>
|
||||||
where
|
where
|
||||||
QC: QueryContext,
|
QC: QueryContext,
|
||||||
{
|
{
|
||||||
storage: Arc<QC::QueryContextStorage>,
|
shared_state: Arc<SharedState<QC>>,
|
||||||
execution_stack: RefCell<Vec<QC::QueryDescriptor>>,
|
execution_stack: RefCell<Vec<QC::QueryDescriptor>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct SharedState<QC>
|
||||||
|
where
|
||||||
|
QC: QueryContext,
|
||||||
|
{
|
||||||
|
storage: QC::QueryContextStorage,
|
||||||
|
revision: AtomicU64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||||
|
pub struct Revision {
|
||||||
|
generation: usize,
|
||||||
|
}
|
||||||
|
|
||||||
impl<QC> Default for Runtime<QC>
|
impl<QC> Default for Runtime<QC>
|
||||||
where
|
where
|
||||||
QC: QueryContext,
|
QC: QueryContext,
|
||||||
{
|
{
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Runtime {
|
Runtime {
|
||||||
storage: Arc::default(),
|
shared_state: Arc::new(SharedState {
|
||||||
|
storage: Default::default(),
|
||||||
|
revision: Default::default(),
|
||||||
|
}),
|
||||||
execution_stack: RefCell::default(),
|
execution_stack: RefCell::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +46,7 @@ where
|
||||||
QC: QueryContext,
|
QC: QueryContext,
|
||||||
{
|
{
|
||||||
pub fn storage(&self) -> &QC::QueryContextStorage {
|
pub fn storage(&self) -> &QC::QueryContextStorage {
|
||||||
&self.storage
|
&self.shared_state.storage
|
||||||
}
|
}
|
||||||
|
|
||||||
crate fn execute_query_implementation<Q>(
|
crate fn execute_query_implementation<Q>(
|
||||||
|
|
Loading…
Reference in a new issue