From bb1c30838054bffb5ba32ee09991222fdef08979 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Sat, 27 Jun 2020 13:40:37 +0300 Subject: [PATCH] Revert "Bump parking_lot and remove workaround" This reverts commit 025c882cbb1e252da56bf09d7e946fbed316bb54. --- Cargo.toml | 3 +-- src/derived/slot.rs | 15 +++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 34a0c05..27d2e24 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,9 +11,8 @@ readme = "README.md" [dependencies] crossbeam = "0.7.1" indexmap = "1.0.1" -lock_api = "0.4" log = "0.4.5" -parking_lot = "0.11.0" +parking_lot = "0.10.0" rustc-hash = "1.0" smallvec = "1.0.0" rand = { version = "0.7", features = [ "small_rng" ] } diff --git a/src/derived/slot.rs b/src/derived/slot.rs index 43a4d08..83a2fd5 100644 --- a/src/derived/slot.rs +++ b/src/derived/slot.rs @@ -15,10 +15,9 @@ use crate::runtime::Runtime; use crate::runtime::RuntimeId; use crate::runtime::StampedValue; use crate::{CycleError, Database, DiscardIf, DiscardWhat, Event, EventKind, SweepStrategy}; -// use lock_api::RawRwLockUpgrade; use log::{debug, info}; use parking_lot::Mutex; -use parking_lot::{RawRwLock, RwLock}; +use parking_lot::RwLock; use smallvec::SmallVec; use std::marker::PhantomData; use std::ops::Deref; @@ -166,13 +165,13 @@ where // Check with an upgradable read to see if there is a value // already. (This permits other readers but prevents anyone // else from running `read_upgrade` at the same time.) - let old_memo = match self.probe(db, self.state.upgradable_read(), runtime, revision_now) { + // + // FIXME(Amanieu/parking_lot#101) -- we are using a write-lock + // and not an upgradable read here because upgradable reads + // can sometimes encounter deadlocks. + let old_memo = match self.probe(db, self.state.write(), runtime, revision_now) { ProbeState::UpToDate(v) => return v, - ProbeState::StaleOrAbsent(state) => { - type RwLockUpgradableReadGuard<'a, T> = - lock_api::RwLockUpgradableReadGuard<'a, RawRwLock, T>; - - let mut state = RwLockUpgradableReadGuard::upgrade(state); + ProbeState::StaleOrAbsent(mut state) => { match std::mem::replace(&mut *state, QueryState::in_progress(runtime.id())) { QueryState::Memoized(old_memo) => Some(old_memo), QueryState::InProgress { .. } => unreachable!(),