@@ -790,8 +790,12 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
790
790
void $ getOptions absFile
791
791
getOptionsLoop
792
792
793
- let getSessionRetry :: FilePath -> IO (IdeResult HscEnvEq , DependencyInfo )
794
- getSessionRetry absFile = do
793
+ -- | Given a file, this function will return the HscEnv and the dependencies
794
+ -- it would look up the cache first, if the cache is not available, it would
795
+ -- submit a request to the getOptionsLoop to get the options for the file
796
+ -- and wait until the options are available
797
+ let lookupOrWaitCache :: FilePath -> IO (IdeResult HscEnvEq , DependencyInfo )
798
+ lookupOrWaitCache absFile = do
795
799
let ncfp = toNormalizedFilePath' absFile
796
800
-- check if in the cache
797
801
res <- atomically $ checkInCache ncfp
@@ -807,21 +811,17 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
807
811
Just r -> return r
808
812
Nothing -> do
809
813
-- if not ok, we need to reload the session
810
- atomically $ do
811
- S. insert absFile pendingFileSet
812
- atomically $ do
813
- -- wait until pendingFiles is not in pendingFiles
814
- Extra. whenM (S. lookup absFile pendingFileSet) STM. retry
815
- getSessionRetry absFile
814
+ atomically $ S. insert absFile pendingFileSet
815
+ -- wait until pendingFiles is not in pendingFiles
816
+ atomically $ Extra. whenM (S. lookup absFile pendingFileSet) STM. retry
817
+ lookupOrWaitCache absFile
816
818
819
+ -- see Note [Serializing runs in separate thread]
817
820
-- Start the getOptionsLoop if the queue is empty
818
821
liftIO $ atomically $ Extra. whenM (isEmptyTQueue que) $ writeTQueue que getOptionsLoop
819
822
returnWithVersion $ \ file -> do
820
823
let absFile = toAbsolutePath file
821
- second Map. keys <$> getSessionRetry absFile
822
- -- atomically $ writeTQueue pendingFiles absFile
823
- -- see Note [Serializing runs in separate thread]
824
- -- awaitRunInThread que $ second Map.keys <$> getOptions absFile
824
+ second Map. keys <$> lookupOrWaitCache absFile
825
825
826
826
-- | Run the specific cradle on a specific FilePath via hie-bios.
827
827
-- This then builds dependencies or whatever based on the cradle, gets the
0 commit comments