mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-02-02 09:46:06 +00:00
introduce Database::salsa_runtime_mut
method (breaking change!)
This commit is contained in:
parent
c789219bc5
commit
b9f00726da
19 changed files with 100 additions and 17 deletions
|
@ -27,9 +27,13 @@ pub struct DatabaseImpl {
|
|||
|
||||
/// This impl tells salsa where to find the salsa runtime.
|
||||
impl salsa::Database for DatabaseImpl {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<DatabaseImpl> {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<Self> {
|
||||
&self.runtime
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> {
|
||||
&mut self.runtime
|
||||
}
|
||||
}
|
||||
|
||||
/// In addition to the "query provider" traits, you may have other
|
||||
|
|
|
@ -79,9 +79,13 @@ struct DatabaseStruct {
|
|||
|
||||
// Tell salsa where to find the runtime in your context.
|
||||
impl salsa::Database for DatabaseStruct {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<DatabaseStruct> {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<Self> {
|
||||
&self.runtime
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> {
|
||||
&mut self.runtime
|
||||
}
|
||||
}
|
||||
|
||||
// This shows how to use a query.
|
||||
|
|
|
@ -27,9 +27,13 @@
|
|||
/// }
|
||||
///
|
||||
/// impl salsa::Database for DatabaseImpl {
|
||||
/// fn salsa_runtime(&self) -> &salsa::Runtime<DatabaseImpl> {
|
||||
/// fn salsa_runtime(&self) -> &salsa::Runtime<Self> {
|
||||
/// &self.runtime
|
||||
/// }
|
||||
///
|
||||
/// fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> {
|
||||
/// &mut self.runtime
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn is_send<T: Send>(_: T) { }
|
||||
|
@ -68,9 +72,13 @@ fn test_key_not_send_db_not_send() {}
|
|||
/// }
|
||||
///
|
||||
/// impl salsa::Database for DatabaseImpl {
|
||||
/// fn salsa_runtime(&self) -> &salsa::Runtime<DatabaseImpl> {
|
||||
/// fn salsa_runtime(&self) -> &salsa::Runtime<Self> {
|
||||
/// &self.runtime
|
||||
/// }
|
||||
///
|
||||
/// fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> {
|
||||
/// &mut self.runtime
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn is_send<T: Send>(_: T) { }
|
||||
|
@ -108,9 +116,13 @@ fn test_key_not_sync_db_not_send() {}
|
|||
/// }
|
||||
///
|
||||
/// impl salsa::Database for DatabaseImpl {
|
||||
/// fn salsa_runtime(&self) -> &salsa::Runtime<DatabaseImpl> {
|
||||
/// fn salsa_runtime(&self) -> &salsa::Runtime<Self> {
|
||||
/// &self.runtime
|
||||
/// }
|
||||
///
|
||||
/// fn salsa_runtime(&mut self) -> &mut salsa::Runtime<Self> {
|
||||
/// &mut self.runtime
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn is_sync<T: Sync>(_: T) { }
|
||||
|
|
|
@ -48,6 +48,9 @@ pub trait Database: plumbing::DatabaseStorageTypes + plumbing::DatabaseOps {
|
|||
/// Gives access to the underlying salsa runtime.
|
||||
fn salsa_runtime(&self) -> &Runtime<Self>;
|
||||
|
||||
/// Gives access to the underlying salsa runtime.
|
||||
fn salsa_runtime_mut(&mut self) -> &mut Runtime<Self>;
|
||||
|
||||
/// Iterates through all query storage and removes any values that
|
||||
/// have not been used since the last revision was created. The
|
||||
/// intended use-cycle is that you first execute all of your
|
||||
|
|
|
@ -12,9 +12,13 @@ struct DatabaseImpl {
|
|||
}
|
||||
|
||||
impl salsa::Database for DatabaseImpl {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<DatabaseImpl> {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<Self> {
|
||||
&self.runtime
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> {
|
||||
&mut self.runtime
|
||||
}
|
||||
}
|
||||
|
||||
impl ParallelDatabase for DatabaseImpl {
|
||||
|
|
|
@ -7,9 +7,13 @@ struct DynTraitDatabase {
|
|||
}
|
||||
|
||||
impl salsa::Database for DynTraitDatabase {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<DynTraitDatabase> {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<Self> {
|
||||
&self.runtime
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> {
|
||||
&mut self.runtime
|
||||
}
|
||||
}
|
||||
|
||||
#[salsa::query_group(DynTraitStorage)]
|
||||
|
|
|
@ -14,6 +14,10 @@ impl salsa::Database for DatabaseImpl {
|
|||
fn salsa_runtime(&self) -> &salsa::Runtime<DatabaseImpl> {
|
||||
&self.runtime
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<DatabaseImpl> {
|
||||
&mut self.runtime
|
||||
}
|
||||
}
|
||||
|
||||
impl DatabaseImpl {
|
||||
|
|
|
@ -55,7 +55,11 @@ impl TestContext for TestContextImpl {
|
|||
}
|
||||
|
||||
impl salsa::Database for TestContextImpl {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<TestContextImpl> {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<Self> {
|
||||
&self.runtime
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> {
|
||||
&mut self.runtime
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,13 @@ struct Database {
|
|||
}
|
||||
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<Database> {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<Self> {
|
||||
&self.runtime
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> {
|
||||
&mut self.runtime
|
||||
}
|
||||
}
|
||||
|
||||
impl salsa::ParallelDatabase for Database {
|
||||
|
|
|
@ -47,9 +47,13 @@ struct Database {
|
|||
}
|
||||
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<Database> {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<Self> {
|
||||
&self.runtime
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> {
|
||||
&mut self.runtime
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -23,9 +23,13 @@ struct DatabaseImpl {
|
|||
}
|
||||
|
||||
impl salsa::Database for DatabaseImpl {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<DatabaseImpl> {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<Self> {
|
||||
&self.runtime
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> {
|
||||
&mut self.runtime
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -43,10 +43,14 @@ struct Database {
|
|||
}
|
||||
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<Database> {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<Self> {
|
||||
&self.runtime
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> {
|
||||
&mut self.runtime
|
||||
}
|
||||
|
||||
fn salsa_event(&self, event_fn: impl Fn() -> salsa::Event<Self>) {
|
||||
if let Some(cb) = &self.on_event {
|
||||
cb(event_fn())
|
||||
|
|
|
@ -30,9 +30,13 @@ struct DatabaseStruct {
|
|||
}
|
||||
|
||||
impl salsa::Database for DatabaseStruct {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<DatabaseStruct> {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<Self> {
|
||||
&self.runtime
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> {
|
||||
&mut self.runtime
|
||||
}
|
||||
}
|
||||
|
||||
impl salsa::ParallelDatabase for DatabaseStruct {
|
||||
|
|
|
@ -192,10 +192,14 @@ pub(crate) struct ParDatabaseImpl {
|
|||
}
|
||||
|
||||
impl Database for ParDatabaseImpl {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<ParDatabaseImpl> {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<Self> {
|
||||
&self.runtime
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> {
|
||||
&mut self.runtime
|
||||
}
|
||||
|
||||
fn salsa_event(&self, event_fn: impl Fn() -> salsa::Event<Self>) {
|
||||
let event = event_fn();
|
||||
match event.kind {
|
||||
|
|
|
@ -45,6 +45,10 @@ impl salsa::Database for StressDatabaseImpl {
|
|||
fn salsa_runtime(&self) -> &salsa::Runtime<StressDatabaseImpl> {
|
||||
&self.runtime
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<StressDatabaseImpl> {
|
||||
&mut self.runtime
|
||||
}
|
||||
}
|
||||
|
||||
impl salsa::ParallelDatabase for StressDatabaseImpl {
|
||||
|
|
|
@ -50,9 +50,13 @@ struct Database {
|
|||
}
|
||||
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<Database> {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<Self> {
|
||||
&self.runtime
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> {
|
||||
&mut self.runtime
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -20,4 +20,8 @@ impl salsa::Database for DatabaseImpl {
|
|||
fn salsa_runtime(&self) -> &salsa::Runtime<DatabaseImpl> {
|
||||
&self.runtime
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<DatabaseImpl> {
|
||||
&mut self.runtime
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,9 +24,13 @@ struct Database {
|
|||
}
|
||||
|
||||
impl salsa::Database for Database {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<Database> {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<Self> {
|
||||
&self.runtime
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> {
|
||||
&mut self.runtime
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -35,9 +35,13 @@ struct DatabaseStruct {
|
|||
}
|
||||
|
||||
impl salsa::Database for DatabaseStruct {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<DatabaseStruct> {
|
||||
fn salsa_runtime(&self) -> &salsa::Runtime<Self> {
|
||||
&self.runtime
|
||||
}
|
||||
|
||||
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> {
|
||||
&mut self.runtime
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue