File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed
session-loader/Development/IDE Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -403,6 +403,9 @@ runWithDb recorder fp k = do
403
403
withAsync (writerThread withWriteDbRetryable chan) $ \ _ -> do
404
404
withHieDb fp (\ readDb -> k (makeWithHieDbRetryable recorder rng readDb) chan)
405
405
where
406
+ progressThread :: TQueue (IO () ) -> IO ()
407
+ progressThread chan = forever $ join $ atomically $ readTQueue chan
408
+
406
409
writerThread :: WithHieDb -> IndexQueue -> IO ()
407
410
writerThread withHieDbRetryable chan = do
408
411
-- Clear the index of any files that might have been deleted since the last run
Original file line number Diff line number Diff line change @@ -927,7 +927,7 @@ indexHieFile se mod_summary srcPath !hash hf = do
927
927
-- Using `bracket`, so even if an exception happen during withHieDb call,
928
928
-- the the ending part of `reportProgress` (which clean the progress indicator) will still be called.
929
929
indexDoneB <- liftIO newBarrier
930
- bracket_ (liftIO $ async (reportProgress indexDoneB optProgressStyle)) (signalBarrier indexDoneB () ) $
930
+ bracket_ (liftIO $ atomically $ writeTQueue indexProgressThread (reportProgress indexDoneB optProgressStyle)) (signalBarrier indexDoneB () ) $
931
931
withHieDb (\ db -> HieDb. addRefsFromLoaded db targetPath (HieDb. RealFile $ fromNormalizedFilePath srcPath) hash hf')
932
932
where
933
933
mod_location = ms_location mod_summary
Original file line number Diff line number Diff line change @@ -245,10 +245,11 @@ instance Pretty Log where
245
245
-- a worker thread.
246
246
data HieDbWriter
247
247
= HieDbWriter
248
- { indexQueue :: IndexQueue
249
- , indexPending :: TVar (HMap. HashMap NormalizedFilePath Fingerprint ) -- ^ Avoid unnecessary/out of date indexing
250
- , indexCompleted :: TVar Int -- ^ to report progress
251
- , indexProgressToken :: Var (Maybe LSP. ProgressToken )
248
+ { indexQueue :: IndexQueue
249
+ , indexPending :: TVar (HMap. HashMap NormalizedFilePath Fingerprint ) -- ^ Avoid unnecessary/out of date indexing
250
+ , indexCompleted :: TVar Int -- ^ to report progress
251
+ , indexProgressToken :: Var (Maybe LSP. ProgressToken )
252
+ , indexProgressThread :: TQueue (IO () )
252
253
-- ^ This is a Var instead of a TVar since we need to do IO to initialise/update, so we need a lock
253
254
}
254
255
@@ -653,6 +654,7 @@ shakeOpen recorder lspEnv defaultConfig idePlugins debouncer
653
654
indexCompleted <- newTVarIO 0
654
655
semanticTokensId <- newTVarIO 0
655
656
indexProgressToken <- newVar Nothing
657
+ indexProgressThread <- newTQueueIO
656
658
let hiedbWriter = HieDbWriter {.. }
657
659
exportsMap <- newTVarIO mempty
658
660
-- lazily initialize the exports map with the contents of the hiedb
You can’t perform that action at this time.
0 commit comments