File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed
ghcide/session-loader/Development/IDE Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -799,8 +799,11 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
799
799
let lookupOrWaitCache :: FilePath -> IO (IdeResult HscEnvEq , DependencyInfo )
800
800
lookupOrWaitCache absFile = do
801
801
let ncfp = toNormalizedFilePath' absFile
802
- -- check if in the cache
803
- res <- atomically $ checkInCache ncfp
802
+ res <- atomically $ do
803
+ -- wait until target file is not in pendingFiles
804
+ Extra. whenM (S. lookup absFile pendingFileSet) STM. retry
805
+ -- check if in the cache
806
+ checkInCache ncfp
804
807
logWith recorder Info $ LogLookupSessionCache absFile
805
808
updateDateRes <- case res of
806
809
Just r -> do
@@ -814,8 +817,6 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
814
817
Nothing -> do
815
818
-- if not ok, we need to reload the session
816
819
atomically $ S. insert absFile pendingFileSet
817
- -- wait until pendingFiles is not in pendingFiles
818
- atomically $ Extra. whenM (S. lookup absFile pendingFileSet) STM. retry
819
820
lookupOrWaitCache absFile
820
821
821
822
-- see Note [Serializing runs in separate thread]
Original file line number Diff line number Diff line change @@ -2,7 +2,9 @@ module Development.IDE.Session.OrderedSet where
2
2
3
3
import Control.Concurrent.STM (STM , TQueue , newTQueueIO )
4
4
import Control.Concurrent.STM.TQueue (readTQueue , writeTQueue )
5
+ import Control.Monad (when )
5
6
import Data.Hashable (Hashable )
7
+ import qualified Focus
6
8
import qualified ListT as LT
7
9
import qualified StmContainers.Set as S
8
10
import StmContainers.Set (Set )
@@ -12,9 +14,8 @@ type OrderedSet a = (TQueue a, Set a)
12
14
13
15
insert :: Hashable a => a -> OrderedSet a -> STM ()
14
16
insert a (que, s) = do
15
- S. insert a s
16
- writeTQueue que a
17
- return ()
17
+ (_, inserted) <- S. focus (Focus. testingIfInserts $ Focus. insert () ) a s
18
+ when inserted $ writeTQueue que a
18
19
19
20
newIO :: Hashable a => IO (OrderedSet a )
20
21
newIO = do
You can’t perform that action at this time.
0 commit comments