@@ -81,15 +81,13 @@ import Data.Void
8181
8282import Control.Concurrent.STM.Stats (atomically , modifyTVar' ,
8383 readTVar , writeTVar )
84- import Control.Concurrent.STM.TQueue
8584import Control.Monad.Trans.Cont (ContT (ContT , runContT ))
8685import Data.Foldable (for_ )
8786import Data.HashMap.Strict (HashMap )
8887import Data.HashSet (HashSet )
8988import qualified Data.HashSet as Set
9089import Database.SQLite.Simple
9190import Development.IDE.Core.Tracing (withTrace )
92- import Development.IDE.Core.WorkerThread (withWorkerQueue )
9391import Development.IDE.Session.Dependency
9492import Development.IDE.Session.Diagnostics (renderCradleError )
9593import Development.IDE.Session.Ghc hiding (Log )
@@ -108,6 +106,7 @@ import qualified Control.Monad.STM as STM
108106import Control.Monad.Trans.Reader
109107import qualified Development.IDE.Session.Ghc as Ghc
110108import qualified Development.IDE.Session.OrderedSet as S
109+ import Development.IDE.WorkerThread
111110import qualified Focus
112111import qualified StmContainers.Map as STM
113112
@@ -133,10 +132,13 @@ data Log
133132 | LogLookupSessionCache ! FilePath
134133 | LogTime ! String
135134 | LogSessionGhc Ghc. Log
135+ | LogSessionWorkerThread LogWorkerThread
136136deriving instance Show Log
137137
138+
138139instance Pretty Log where
139140 pretty = \ case
141+ LogSessionWorkerThread lt -> pretty lt
140142 LogTime s -> " Time:" <+> pretty s
141143 LogLookupSessionCache path -> " Looking up session cache for" <+> pretty path
142144 LogGetOptionsLoop fp -> " Loop: getOptions for" <+> pretty fp
@@ -362,7 +364,7 @@ runWithDb recorder fp = ContT $ \k -> do
362364 _ <- withWriteDbRetryable deleteMissingRealFiles
363365 _ <- withWriteDbRetryable garbageCollectTypeNames
364366
365- runContT (withWorkerQueue (writer withWriteDbRetryable)) $ \ chan ->
367+ runContT (withWorkerQueue (logWith (cmapWithPrio LogSessionWorkerThread recorder) Debug ) " hiedb thread " ( writer withWriteDbRetryable)) $ \ chan ->
366368 withHieDb fp (\ readDb -> k (WithHieDbShield $ makeWithHieDbRetryable recorder rng readDb, chan))
367369 where
368370 writer withHieDbRetryable l = do
@@ -589,7 +591,7 @@ newSessionState = do
589591-- components mapping to the same hie.yaml file are mapped to the same
590592-- HscEnv which is updated as new components are discovered.
591593
592- loadSessionWithOptions :: Recorder (WithPriority Log ) -> SessionLoadingOptions -> FilePath -> TQueue (IO () ) -> IO (Action IdeGhcSession )
594+ loadSessionWithOptions :: Recorder (WithPriority Log ) -> SessionLoadingOptions -> FilePath -> TaskQueue (IO () ) -> IO (Action IdeGhcSession )
593595loadSessionWithOptions recorder SessionLoadingOptions {.. } rootDir que = do
594596 let toAbsolutePath = toAbsolute rootDir -- see Note [Root Directory]
595597
@@ -617,7 +619,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
617619
618620 -- see Note [Serializing runs in separate thread]
619621 -- Start the getOptionsLoop if the queue is empty
620- liftIO $ atomically $ Extra. whenM (isEmptyTQueue que) $ do
622+ liftIO $ atomically $ Extra. whenM (isEmptyTaskQueue que) $ do
621623 let newSessionLoadingOptions = SessionLoadingOptions
622624 { findCradle = cradleLoc
623625 , ..
@@ -636,7 +638,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
636638 , sessionLoadingOptions = newSessionLoadingOptions
637639 }
638640
639- writeTQueue que (runReaderT (getOptionsLoop recorder sessionShake sessionState knownTargetsVar) sessionEnv)
641+ writeTaskQueue que (runReaderT (getOptionsLoop recorder sessionShake sessionState knownTargetsVar) sessionEnv)
640642
641643 -- Each one of deps will be registered as a FileSystemWatcher in the GhcSession action
642644 -- so that we can get a workspace/didChangeWatchedFiles notification when a dep changes.
@@ -935,7 +937,7 @@ loadCradleWithNotifications recorder sessionState loadCradle hieYaml cfp = do
935937 when (isNothing hieYaml) $
936938 logWith recorder Warning $ LogCradleNotFound lfpLog
937939 cradle <- liftIO $ loadCradle hieYaml rootDir
938- when ( isTesting) $ mRunLspT lspEnv $
940+ when isTesting $ mRunLspT lspEnv $
939941 sendNotification (SMethod_CustomMethod (Proxy @ " ghcide/cradle/loaded" )) (toJSON cfp)
940942
941943 -- Display a user friendly progress message here: They probably don't know what a cradle is
@@ -1034,7 +1036,7 @@ data PackageSetupException
10341036 { compileTime :: ! Version
10351037 , runTime :: ! Version
10361038 }
1037- deriving (Eq , Show , Typeable )
1039+ deriving (Eq , Show )
10381040
10391041instance Exception PackageSetupException
10401042
0 commit comments