Skip to content

Commit a4baa97

Browse files
committed
make garbage collection async
1 parent 0bd1d96 commit a4baa97

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
@@ -135,20 +135,21 @@ runWithDb fp k = do
135135
`catch` \IncompatibleSchemaVersion{} -> removeFile fp
136136
withHieDb fp $ \writedb -> do
137137
initConn writedb
138-
-- Clear the index of any files that might have been deleted since the last run
139-
deleteMissingRealFiles writedb
140-
_ <- garbageCollectTypeNames writedb
141138
chan <- newTQueueIO
142139
withAsync (writerThread writedb chan) $ \_ -> do
143140
withHieDb fp (flip k chan)
144141
where
145-
writerThread db chan = forever $ do
146-
k <- atomically $ readTQueue chan
147-
k db
148-
`catch` \e@SQLError{} -> do
149-
hPutStrLn stderr $ "SQLite error in worker, ignoring: " ++ show e
150-
`catchAny` \e -> do
151-
hPutStrLn stderr $ "Uncaught error in database worker, ignoring: " ++ show e
142+
writerThread db chan = do
143+
-- Clear the index of any files that might have been deleted since the last run
144+
deleteMissingRealFiles db
145+
_ <- garbageCollectTypeNames db
146+
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
152153

153154

154155
getHieDbLoc :: FilePath -> IO FilePath

0 commit comments

Comments
 (0)