require &mut self for with_incremented_revision

This commit is contained in:
Niko Matsakis 2019-09-27 05:54:42 -04:00
parent 236c2eae84
commit b0710416d0
4 changed files with 10 additions and 9 deletions

View file

@ -197,8 +197,8 @@ where
DB: Database + HasQueryGroup<Q::Group>,
MP: MemoizationPolicy<DB, Q>,
{
fn invalidate(&self, db: &DB, key: &Q::Key) {
db.salsa_runtime().with_incremented_revision(|guard| {
fn invalidate(&self, db: &mut DB, key: &Q::Key) {
db.salsa_runtime_mut().with_incremented_revision(|guard| {
let map_read = self.slot_map.read();
if let Some(slot) = map_read.get(key) {

View file

@ -130,7 +130,7 @@ where
{
fn set(
&self,
db: &DB,
db: &mut DB,
key: &Q::Key,
database_key: &DB::DatabaseKey,
value: Q::Value,
@ -166,7 +166,7 @@ where
// keys, we only need a new revision if the key used to
// exist. But we may add such methods in the future and this
// case doesn't generally seem worth optimizing for.
db.salsa_runtime().with_incremented_revision(|guard| {
db.salsa_runtime_mut().with_incremented_revision(|guard| {
let mut slots = self.slots.write();
// Do this *after* we acquire the lock, so that we are not

View file

@ -176,7 +176,7 @@ where
{
fn set(
&self,
db: &DB,
db: &mut DB,
key: &Q::Key,
database_key: &DB::DatabaseKey,
new_value: Q::Value,
@ -196,5 +196,5 @@ where
DB: Database,
Q: Query<DB>,
{
fn invalidate(&self, db: &DB, key: &Q::Key);
fn invalidate(&self, db: &mut DB, key: &Q::Key);
}

View file

@ -295,7 +295,7 @@ where
/// thread is attempting to increment the global revision at a
/// time.
pub(crate) fn with_incremented_revision<R>(
&self,
&mut self,
op: impl FnOnce(&DatabaseWriteLockGuard<'_, DB>) -> R,
) -> R {
log::debug!("increment_revision()");
@ -309,7 +309,8 @@ where
let current_revision = self.shared_state.pending_revision.fetch_then_increment();
// To modify the revision, we need the lock.
let _lock = self.shared_state.query_lock.write();
let shared_state = self.shared_state.clone();
let _lock = shared_state.query_lock.write();
let old_revision = self.shared_state.revisions[0].fetch_then_increment();
assert_eq!(current_revision, old_revision);
@ -529,7 +530,7 @@ pub(crate) struct DatabaseWriteLockGuard<'db, DB>
where
DB: Database,
{
runtime: &'db Runtime<DB>,
runtime: &'db mut Runtime<DB>,
new_revision: Revision,
}