@@ -453,6 +453,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
453
453
-- you have to modify 'filesMap' as well.
454
454
filesMap <- newVar HM. empty :: IO (Var FilesMap )
455
455
-- Version of the mappings above
456
+ pendingFilesTQueue <- newTQueueIO
456
457
version <- newVar 0
457
458
biosSessionLoadingVar <- newVar Nothing :: IO (Var (Maybe SessionLoadingPreferenceConfig ))
458
459
let returnWithVersion fun = IdeGhcSession fun <$> liftIO (readVar version)
@@ -474,7 +475,6 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
474
475
let invalidateShakeCache = do
475
476
void $ modifyVar' version succ
476
477
return $ toNoFileKey GhcSessionIO
477
- OfInterestVar filesOfInterVar <- getIdeGlobalAction
478
478
IdeOptions { optTesting = IdeTesting optTesting
479
479
, optCheckProject = getCheckProject
480
480
, optExtensions
@@ -728,31 +728,23 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
728
728
sessionOptsList yamlFiles
729
729
730
730
731
-
732
731
-- The main function which gets options for a file. We only want one of these running
733
732
-- at a time. Therefore the IORef contains the currently running cradle, if we try
734
733
-- to get some more options then we wait for the currently running action to finish
735
734
-- before attempting to do so.
736
- -- let getOptions :: FilePath -> IO (IdeResult HscEnvEq, [FilePath])
737
- -- getOptions file = do
738
- -- let ncfp = toNormalizedFilePath' (toAbsolutePath file)
739
- -- cachedHieYamlLocation <- HM.lookup ncfp <$> readVar filesMap
740
- -- hieYaml <- cradleLoc file
741
- -- sessionOpts (join cachedHieYamlLocation <|> hieYaml, file) `Safe.catch` \e ->
742
- -- return (([renderPackageSetupException file e], Nothing), maybe [] pure hieYaml)
743
-
744
735
let getOptionsBatch :: FilePath -> IO (IdeResult HscEnvEq , [FilePath ])
745
736
getOptionsBatch file' = do
737
+ pendingFiles <- atomically $ flushTQueue pendingFilesTQueue
746
738
let file = toAbsolutePath file'
747
739
hieYaml <- cradleLoc file
748
- filesOfInterest <- HashMap. keys <$> readVar filesOfInterVar
749
740
logWith recorder Debug LogSettingInitialDynFlags
750
- results <- getOptionsList (Set. toList $ Set. fromList $ toAbsolutePath file : map fromNormalizedFilePath filesOfInterest )
741
+ results <- getOptionsList (Set. toList $ Set. fromList $ toAbsolutePath file : map fromNormalizedFilePath pendingFiles )
751
742
return (results Map. ! file) `Safe.catch` \ e ->
752
743
return (([renderPackageSetupException file e], Nothing ), maybe [] pure hieYaml)
753
744
754
745
returnWithVersion $ \ file -> do
755
746
-- see Note [Serializing runs in separate thread]
747
+ atomically $ writeTQueue pendingFilesTQueue file
756
748
awaitRunInThread que $ getOptionsBatch file
757
749
758
750
-- cradleToType :: Cradle Void -> IO ()
0 commit comments