@@ -790,8 +790,12 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
790790 void $ getOptions absFile
791791 getOptionsLoop
792792
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
795799 let ncfp = toNormalizedFilePath' absFile
796800 -- check if in the cache
797801 res <- atomically $ checkInCache ncfp
@@ -807,21 +811,17 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
807811 Just r -> return r
808812 Nothing -> do
809813 -- 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
816818
819+ -- see Note [Serializing runs in separate thread]
817820 -- Start the getOptionsLoop if the queue is empty
818821 liftIO $ atomically $ Extra. whenM (isEmptyTQueue que) $ writeTQueue que getOptionsLoop
819822 returnWithVersion $ \ file -> do
820823 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
825825
826826-- | Run the specific cradle on a specific FilePath via hie-bios.
827827-- This then builds dependencies or whatever based on the cradle, gets the
0 commit comments