Skip to content

Commit 35ed108

Browse files
committed
lock-less persistentKeys
1 parent d5673be commit 35ed108

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ghcide/src/Development/IDE/Core/Shake.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ data ShakeExtras = ShakeExtras
219219
,clientCapabilities :: ClientCapabilities
220220
, hiedb :: HieDb -- ^ Use only to read.
221221
, hiedbWriter :: HieDbWriter -- ^ use to write
222-
, persistentKeys :: Var (HMap.HashMap Key GetStalePersistent)
222+
, persistentKeys :: IORef (HMap.HashMap Key GetStalePersistent)
223223
-- ^ Registery for functions that compute/get "stale" results for the rule
224224
-- (possibly from disk)
225225
, vfs :: VFSHandle
@@ -259,7 +259,7 @@ getPluginConfig plugin = do
259259
addPersistentRule :: IdeRule k v => k -> (NormalizedFilePath -> IdeAction (Maybe (v,PositionDelta,TextDocumentVersion))) -> Rules ()
260260
addPersistentRule k getVal = do
261261
ShakeExtras{persistentKeys} <- getShakeExtrasRules
262-
void $ liftIO $ modifyVar' persistentKeys $ HMap.insert (Key k) (fmap (fmap (first3 toDyn)) . getVal)
262+
void $ liftIO $ atomicModifyIORef'_ persistentKeys $ HMap.insert (Key k) (fmap (fmap (first3 toDyn)) . getVal)
263263

264264
class Typeable a => IsIdeGlobal a where
265265

@@ -334,7 +334,7 @@ lastValueIO s@ShakeExtras{positionMapping,persistentKeys,state} k file = do
334334
| IdeTesting testing <- ideTesting s -- Don't read stale persistent values in tests
335335
, testing = pure Nothing
336336
| otherwise = do
337-
pmap <- readVar persistentKeys
337+
pmap <- readIORef persistentKeys
338338
mv <- runMaybeT $ do
339339
liftIO $ Logger.logDebug (logger s) $ T.pack $ "LOOKUP UP PERSISTENT FOR: " ++ show k
340340
f <- MaybeT $ pure $ HMap.lookup (Key k) pmap
@@ -517,7 +517,7 @@ shakeOpen lspEnv defaultConfig logger debouncer
517517
positionMapping <- STM.newIO
518518
knownTargetsVar <- newIORef $ hashed HMap.empty
519519
let restartShakeSession = shakeRestart ideState
520-
persistentKeys <- newVar HMap.empty
520+
persistentKeys <- newIORef HMap.empty
521521
indexPending <- newTVarIO HMap.empty
522522
indexCompleted <- newTVarIO 0
523523
indexProgressToken <- newVar Nothing

0 commit comments

Comments
 (0)