Skip to content

Commit 6bad9ea

Browse files
committed
make garbage collection async
1 parent 0b1cff9 commit 6bad9ea

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

ghcide/session-loader/Development/IDE/Session.hs

+11-10
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,21 @@ runWithDb fp k = do
136136
`catch` \IncompatibleSchemaVersion{} -> removeFile fp
137137
withHieDb fp $ \writedb -> do
138138
initConn writedb
139-
-- Clear the index of any files that might have been deleted since the last run
140-
deleteMissingRealFiles writedb
141-
_ <- garbageCollectTypeNames writedb
142139
chan <- newTQueueIO
143140
withAsync (writerThread writedb chan) $ \_ -> do
144141
withHieDb fp (flip k chan)
145142
where
146-
writerThread db chan = forever $ do
147-
k <- atomically $ readTQueue chan
148-
k db
149-
`catch` \e@SQLError{} -> do
150-
hPutStrLn stderr $ "SQLite error in worker, ignoring: " ++ show e
151-
`catchAny` \e -> do
152-
hPutStrLn stderr $ "Uncaught error in database worker, ignoring: " ++ show e
143+
writerThread db chan = do
144+
-- Clear the index of any files that might have been deleted since the last run
145+
deleteMissingRealFiles db
146+
_ <- garbageCollectTypeNames db
147+
forever $ do
148+
k <- atomically $ readTQueue chan
149+
k db
150+
`catch` \e@SQLError{} -> do
151+
hPutStrLn stderr $ "SQLite error in worker, ignoring: " ++ show e
152+
`catchAny` \e -> do
153+
hPutStrLn stderr $ "Uncaught error in database worker, ignoring: " ++ show e
153154

154155

155156
getHieDbLoc :: FilePath -> IO FilePath

0 commit comments

Comments
 (0)