mirror of
https://github.com/salsa-rs/salsa.git
synced 2024-11-24 20:20:26 +00:00
give salsa_runtime a default implementation
This commit is contained in:
parent
f5b0ff59d3
commit
6776919f39
22 changed files with 16 additions and 184 deletions
|
@ -47,14 +47,6 @@ impl Default for Database {
|
|||
|
||||
// ANCHOR: db_impl
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime {
|
||||
self.storage.runtime()
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime {
|
||||
self.storage.runtime_mut()
|
||||
}
|
||||
|
||||
fn salsa_event(&self, event: salsa::Event) {
|
||||
// Log interesting events, if logging is enabled
|
||||
if let Some(logs) = &self.logs {
|
||||
|
|
|
@ -11,9 +11,9 @@ pub trait Database: HasJarsDyn + AsSalsaDatabase {
|
|||
log::debug!("salsa_event: {:?}", event.debug(self));
|
||||
}
|
||||
|
||||
fn salsa_runtime(&self) -> &Runtime;
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut Runtime;
|
||||
fn salsa_runtime(&self) -> &Runtime {
|
||||
self.runtime()
|
||||
}
|
||||
}
|
||||
|
||||
/// Indicates a database that also supports parallel query
|
||||
|
|
|
@ -51,14 +51,6 @@ struct Database {
|
|||
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_event(&self, _event: salsa::Event) {}
|
||||
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime {
|
||||
self.storage.runtime()
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime {
|
||||
self.storage.runtime_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl Db for Database {}
|
||||
|
|
|
@ -55,14 +55,6 @@ struct Database {
|
|||
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_event(&self, _event: salsa::Event) {}
|
||||
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime {
|
||||
self.storage.runtime()
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime {
|
||||
self.storage.runtime_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl Db for Database {}
|
||||
|
|
|
@ -50,14 +50,6 @@ struct Database {
|
|||
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_event(&self, _event: salsa::Event) {}
|
||||
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime {
|
||||
self.storage.runtime()
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime {
|
||||
self.storage.runtime_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl Db for Database {}
|
||||
|
|
|
@ -70,14 +70,6 @@ struct Database {
|
|||
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_event(&self, _event: salsa::Event) {}
|
||||
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime {
|
||||
self.storage.runtime()
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime {
|
||||
self.storage.runtime_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl Db for Database {}
|
||||
|
|
|
@ -78,18 +78,10 @@ struct Database {
|
|||
storage: salsa::Storage<Self>,
|
||||
}
|
||||
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime {
|
||||
self.storage.runtime()
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime {
|
||||
self.storage.runtime_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl Db for Database {}
|
||||
|
||||
impl salsa::Database for Database {}
|
||||
|
||||
impl RefUnwindSafe for Database {}
|
||||
|
||||
#[salsa::input(jar = Jar)]
|
||||
|
|
|
@ -30,15 +30,7 @@ struct Database {
|
|||
storage: salsa::Storage<Self>,
|
||||
}
|
||||
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime {
|
||||
self.storage.runtime()
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime {
|
||||
self.storage.runtime_mut()
|
||||
}
|
||||
}
|
||||
impl salsa::Database for Database {}
|
||||
|
||||
impl Db for Database {}
|
||||
|
||||
|
|
|
@ -76,14 +76,6 @@ impl salsa::Database for Database {
|
|||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime {
|
||||
self.storage.runtime()
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime {
|
||||
self.storage.runtime_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl Db for Database {}
|
||||
|
|
|
@ -69,14 +69,6 @@ impl salsa::Database for Database {
|
|||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime {
|
||||
self.storage.runtime()
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime {
|
||||
self.storage.runtime_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl Db for Database {}
|
||||
|
|
|
@ -53,15 +53,7 @@ struct Database {
|
|||
logger: Logger,
|
||||
}
|
||||
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime {
|
||||
self.storage.runtime()
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime {
|
||||
self.storage.runtime_mut()
|
||||
}
|
||||
}
|
||||
impl salsa::Database for Database {}
|
||||
|
||||
impl Db for Database {}
|
||||
|
||||
|
|
|
@ -37,15 +37,7 @@ struct Database {
|
|||
logger: Logger,
|
||||
}
|
||||
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime {
|
||||
self.storage.runtime()
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime {
|
||||
self.storage.runtime_mut()
|
||||
}
|
||||
}
|
||||
impl salsa::Database for Database {}
|
||||
|
||||
impl Db for Database {}
|
||||
|
||||
|
|
|
@ -40,15 +40,7 @@ struct Database {
|
|||
logger: Logger,
|
||||
}
|
||||
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime {
|
||||
self.storage.runtime()
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime {
|
||||
self.storage.runtime_mut()
|
||||
}
|
||||
}
|
||||
impl salsa::Database for Database {}
|
||||
|
||||
impl Db for Database {}
|
||||
|
||||
|
|
|
@ -66,15 +66,7 @@ struct Database {
|
|||
logger: Logger,
|
||||
}
|
||||
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime {
|
||||
self.storage.runtime()
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime {
|
||||
self.storage.runtime_mut()
|
||||
}
|
||||
}
|
||||
impl salsa::Database for Database {}
|
||||
|
||||
impl Db for Database {}
|
||||
|
||||
|
|
|
@ -22,15 +22,7 @@ struct Database {
|
|||
logger: Logger,
|
||||
}
|
||||
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime {
|
||||
self.storage.runtime()
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime {
|
||||
self.storage.runtime_mut()
|
||||
}
|
||||
}
|
||||
impl salsa::Database for Database {}
|
||||
|
||||
impl Db for Database {}
|
||||
|
||||
|
|
|
@ -72,15 +72,7 @@ fn execute() {
|
|||
storage: salsa::Storage<Self>,
|
||||
}
|
||||
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime {
|
||||
self.storage.runtime()
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime {
|
||||
self.storage.runtime_mut()
|
||||
}
|
||||
}
|
||||
impl salsa::Database for Database {}
|
||||
|
||||
impl Db for Database {}
|
||||
|
||||
|
|
|
@ -38,19 +38,11 @@ pub(crate) struct Database {
|
|||
}
|
||||
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime {
|
||||
self.storage.runtime()
|
||||
}
|
||||
|
||||
fn salsa_event(&self, event: salsa::Event) {
|
||||
if let salsa::EventKind::WillBlockOn { .. } = event.kind {
|
||||
self.signal(self.knobs().signal_on_will_block.get());
|
||||
}
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime {
|
||||
self.storage.runtime_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl salsa::ParallelDatabase for Database {
|
||||
|
|
|
@ -72,14 +72,6 @@ struct Database {
|
|||
}
|
||||
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime {
|
||||
self.storage.runtime()
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime {
|
||||
self.storage.runtime_mut()
|
||||
}
|
||||
|
||||
fn salsa_event(&self, event: salsa::Event) {
|
||||
self.push_log(format!("{:?}", event.debug(self)));
|
||||
}
|
||||
|
|
|
@ -25,15 +25,7 @@ fn execute() {
|
|||
storage: salsa::Storage<Self>,
|
||||
}
|
||||
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime {
|
||||
self.storage.runtime()
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime {
|
||||
self.storage.runtime_mut()
|
||||
}
|
||||
}
|
||||
impl salsa::Database for Database {}
|
||||
|
||||
impl Db for Database {}
|
||||
|
||||
|
|
|
@ -27,15 +27,7 @@ struct Database {
|
|||
storage: salsa::Storage<Self>,
|
||||
}
|
||||
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime {
|
||||
self.storage.runtime()
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime {
|
||||
self.storage.runtime_mut()
|
||||
}
|
||||
}
|
||||
impl salsa::Database for Database {}
|
||||
|
||||
impl Db for Database {}
|
||||
|
||||
|
|
|
@ -37,15 +37,7 @@ struct Database {
|
|||
storage: salsa::Storage<Self>,
|
||||
}
|
||||
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime {
|
||||
self.storage.runtime()
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime {
|
||||
self.storage.runtime_mut()
|
||||
}
|
||||
}
|
||||
impl salsa::Database for Database {}
|
||||
|
||||
impl Db for Database {}
|
||||
|
||||
|
|
|
@ -41,15 +41,7 @@ struct Database {
|
|||
logger: Logger,
|
||||
}
|
||||
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime {
|
||||
self.storage.runtime()
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime {
|
||||
self.storage.runtime_mut()
|
||||
}
|
||||
}
|
||||
impl salsa::Database for Database {}
|
||||
|
||||
impl Db for Database {}
|
||||
|
||||
|
|
Loading…
Reference in a new issue