@@ -780,8 +780,9 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
780
780
-- at a time. Therefore the IORef contains the currently running cradle, if we try
781
781
-- to get some more options then we wait for the currently running action to finish
782
782
-- before attempting to do so.
783
- let getOptions :: FilePath -> IO ()
784
- getOptions file = do
783
+ let getOptionsWorker :: FilePath -> IO ()
784
+ getOptionsWorker file = do
785
+ logWith recorder Info (LogGetOptionsLoop file)
785
786
let ncfp = toNormalizedFilePath' file
786
787
cachedHieYamlLocation <- atomically $ STM. lookup ncfp filesMap
787
788
hieYaml <- cradleLoc file
@@ -795,14 +796,6 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
795
796
-- delete file from pending files
796
797
S. delete file pendingFileSet
797
798
798
- let getOptionsLoop :: IO ()
799
- getOptionsLoop = do
800
- -- Get the next file to load
801
- absFile <- atomically $ S. readQueue pendingFileSet
802
- logWith recorder Info (LogGetOptionsLoop absFile)
803
- getOptions absFile
804
- getOptionsLoop
805
-
806
799
-- | Given a file, this function will return the HscEnv and the dependencies
807
800
-- it would look up the cache first, if the cache is not available, it would
808
801
-- submit a request to the getOptionsLoop to get the options for the file
@@ -828,11 +821,12 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
828
821
Nothing -> do
829
822
-- if not ok, we need to reload the session
830
823
atomically $ S. insert absFile pendingFileSet
824
+ -- line up the session to load
825
+ atomically $ writeTQueue que (getOptionsWorker absFile)
831
826
lookupOrWaitCache absFile
832
827
833
828
-- see Note [Serializing runs in separate thread]
834
829
-- Start the getOptionsLoop if the queue is empty
835
- liftIO $ atomically $ Extra. whenM (isEmptyTQueue que) $ writeTQueue que getOptionsLoop
836
830
returnWithVersion $ \ file -> do
837
831
let absFile = toAbsolutePath file
838
832
second Map. keys <$> lookupOrWaitCache absFile
0 commit comments