Skip to content

Commit 3045558

Browse files
committed
lock-less persistentKeys
1 parent f221670 commit 3045558

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
@@ -220,7 +220,7 @@ data ShakeExtras = ShakeExtras
220220
,clientCapabilities :: ClientCapabilities
221221
, hiedb :: HieDb -- ^ Use only to read.
222222
, hiedbWriter :: HieDbWriter -- ^ use to write
223-
, persistentKeys :: Var (HMap.HashMap Key GetStalePersistent)
223+
, persistentKeys :: IORef (HMap.HashMap Key GetStalePersistent)
224224
-- ^ Registery for functions that compute/get "stale" results for the rule
225225
-- (possibly from disk)
226226
, vfs :: VFSHandle
@@ -260,7 +260,7 @@ getPluginConfig plugin = do
260260
addPersistentRule :: IdeRule k v => k -> (NormalizedFilePath -> IdeAction (Maybe (v,PositionDelta,TextDocumentVersion))) -> Rules ()
261261
addPersistentRule k getVal = do
262262
ShakeExtras{persistentKeys} <- getShakeExtrasRules
263-
void $ liftIO $ modifyVar' persistentKeys $ HMap.insert (Key k) (fmap (fmap (first3 toDyn)) . getVal)
263+
void $ liftIO $ atomicModifyIORef'_ persistentKeys $ HMap.insert (Key k) (fmap (fmap (first3 toDyn)) . getVal)
264264

265265
class Typeable a => IsIdeGlobal a where
266266

@@ -328,7 +328,7 @@ lastValueIO s@ShakeExtras{positionMapping,persistentKeys,state} k file = do
328328
| IdeTesting testing <- ideTesting s -- Don't read stale persistent values in tests
329329
, testing = pure Nothing
330330
| otherwise = do
331-
pmap <- readVar persistentKeys
331+
pmap <- readIORef persistentKeys
332332
mv <- runMaybeT $ do
333333
liftIO $ Logger.logDebug (logger s) $ T.pack $ "LOOKUP UP PERSISTENT FOR: " ++ show k
334334
f <- MaybeT $ pure $ HMap.lookup (Key k) pmap
@@ -509,7 +509,7 @@ shakeOpen lspEnv defaultConfig logger debouncer
509509
positionMapping <- STM.newIO
510510
knownTargetsVar <- newIORef $ hashed HMap.empty
511511
let restartShakeSession = shakeRestart ideState
512-
persistentKeys <- newVar HMap.empty
512+
persistentKeys <- newIORef HMap.empty
513513
indexPending <- newTVarIO HMap.empty
514514
indexCompleted <- newTVarIO 0
515515
indexProgressToken <- newVar Nothing

0 commit comments

Comments
 (0)