@@ -27,7 +27,7 @@ module Development.IDE.Core.Shake(
2727 KnownTargets (.. ), Target (.. ), toKnownFiles , unionKnownTargets , mkKnownTargets ,
2828 ShakeRestartArgs (.. ),
2929 shakeRestart ,
30- IdeRule , IdeResult , RestartQueue ,
30+ IdeRule , IdeResult , ShakeControlQueue ,
3131 GetModificationTime (GetModificationTime , GetModificationTime_ , missingFileDiagnostics ),
3232 shakeOpen , shakeShut ,
3333 shakeEnqueue ,
@@ -78,7 +78,7 @@ module Development.IDE.Core.Shake(
7878 Log (.. ),
7979 VFSModified (.. ), getClientConfigAction ,
8080 ThreadQueue (.. ),
81- runWithSignal , runRestartTask , runRestartTaskDync , dynShakeRestart
81+ runWithSignal , runRestartTask , runRestartTaskDyn , dynShakeRestart
8282 ) where
8383
8484import Control.Concurrent.Async
@@ -289,16 +289,16 @@ data HieDbWriter
289289-- The inner `(HieDb -> IO ()) -> IO ()` wraps `HieDb -> IO ()`
290290-- with (currently) retry functionality
291291type IndexQueue = TaskQueue (((HieDb -> IO () ) -> IO () ) -> IO () )
292- -- type RestartQueue = TaskQueue ShakeRestartArgs
292+ -- type ShakeControlQueue = TaskQueue ShakeRestartArgs
293293type ShakeQueue = DBQue
294- type RestartQueue = ShakeQueue
294+ type ShakeControlQueue = ShakeQueue
295295type LoaderQueue = TaskQueue (IO () )
296296
297297
298298data ThreadQueue = ThreadQueue {
299- tIndexQueue :: IndexQueue
300- , tRestartQueue :: RestartQueue
301- , tLoaderQueue :: LoaderQueue
299+ tIndexQueue :: IndexQueue
300+ , tShakeControlQueue :: ShakeControlQueue
301+ , tLoaderQueue :: LoaderQueue
302302}
303303
304304-- Note [Semantic Tokens Cache Location]
@@ -369,7 +369,7 @@ data ShakeExtras = ShakeExtras
369369 -- ^ Default HLS config, only relevant if the client does not provide any Config
370370 , dirtyKeys :: TVar KeySet
371371 -- ^ Set of dirty rule keys since the last Shake run
372- , restartQueue :: RestartQueue
372+ , shakeControlQueue :: ShakeControlQueue
373373 -- ^ Queue of restart actions to be run.
374374 , loaderQueue :: LoaderQueue
375375 -- ^ Queue of loader actions to be run.
@@ -707,7 +707,7 @@ shakeOpen recorder lspEnv defaultConfig idePlugins debouncer
707707 withHieDb threadQueue opts argMonitoring rules rootDir = mdo
708708 -- see Note [Serializing runs in separate thread]
709709 let indexQueue = tIndexQueue threadQueue
710- restartQueue = tRestartQueue threadQueue
710+ shakeControlQueue = tShakeControlQueue threadQueue
711711 loaderQueue = tLoaderQueue threadQueue
712712
713713 ideNc <- initNameCache ' r' knownKeyNames
@@ -720,7 +720,7 @@ shakeOpen recorder lspEnv defaultConfig idePlugins debouncer
720720 semanticTokensCache <- STM. newIO
721721 positionMapping <- STM. newIO
722722 knownTargetsVar <- newTVarIO $ hashed emptyKnownTargets
723- let restartShakeSession = shakeRestart restartQueue
723+ let restartShakeSession = shakeRestart shakeControlQueue
724724 persistentKeys <- newTVarIO mempty
725725 indexPending <- newTVarIO HMap. empty
726726 indexCompleted <- newTVarIO 0
@@ -751,7 +751,7 @@ shakeOpen recorder lspEnv defaultConfig idePlugins debouncer
751751 pure ShakeExtras {shakeRecorder = recorder, .. }
752752 shakeDb <-
753753 shakeNewDatabase
754- restartQueue
754+ shakeControlQueue
755755 opts { shakeExtra = newShakeExtra shakeExtras }
756756 rules
757757 shakeSession <- newEmptyMVar
@@ -855,13 +855,13 @@ delayedAction a = do
855855
856856
857857data ShakeRestartArgs = ShakeRestartArgs
858- { sraVfs :: ! VFSModified
859- , sraReason :: ! String
860- , sraActions :: ! [DelayedAction () ]
861- , sraBetweenSessions :: IO [Key ]
862- , sraReStartQueue :: ! RestartQueue
863- , sraCount :: ! Int
864- , sraWaitMVars :: ! [MVar () ]
858+ { sraVfs :: ! VFSModified
859+ , sraReason :: ! String
860+ , sraActions :: ! [DelayedAction () ]
861+ , sraBetweenSessions :: IO [Key ]
862+ , sraShakeControlQueue :: ! ShakeControlQueue
863+ , sraCount :: ! Int
864+ , sraWaitMVars :: ! [MVar () ]
865865 -- ^ Just for debugging, how many restarts have been requested so far
866866 }
867867
@@ -878,18 +878,20 @@ instance Semigroup ShakeRestartArgs where
878878 , sraReason = sraReason a ++ " ; " ++ sraReason b
879879 , sraActions = sraActions a ++ sraActions b
880880 , sraBetweenSessions = (++) <$> sraBetweenSessions a <*> sraBetweenSessions b
881- , sraReStartQueue = sraReStartQueue a
881+ , sraShakeControlQueue = sraShakeControlQueue a
882882 , sraCount = sraCount a + sraCount b
883883 , sraWaitMVars = sraWaitMVars a ++ sraWaitMVars b
884884 }
885885
886886-- | Restart the current 'ShakeSession' with the given system actions.
887887-- Any actions running in the current session will be aborted,
888888-- but actions added via 'shakeEnqueue' will be requeued.
889- shakeRestart :: RestartQueue -> VFSModified -> String -> [DelayedAction () ] -> IO [Key ] -> IO ()
889+ shakeRestart :: ShakeControlQueue -> VFSModified -> String -> [DelayedAction () ] -> IO [Key ] -> IO ()
890890shakeRestart rts vfs reason acts ioActionBetweenShakeSession = do
891891 waitMVar <- newEmptyMVar
892- void $ submitWork rts $ Left $
892+ -- submit at the head of the queue,
893+ -- prefer restart request over any pending actions
894+ void $ submitWorkAtHead rts $ Left $
893895 toDyn $ ShakeRestartArgs vfs reason acts ioActionBetweenShakeSession rts 1 [waitMVar]
894896 -- Wait until the restart is done
895897 takeMVar waitMVar
@@ -901,8 +903,8 @@ dynShakeRestart dy = case fromDynamic dy of
901903
902904-- runRestartTask :: Recorder (WithPriority Log) -> IdeState -> VFSModified -> String -> [DelayedAction ()] -> IO [Key] -> IO ()
903905-- runRestartTask recorder IdeState{..} vfs reason acts ioActionBetweenShakeSession =
904- runRestartTaskDync :: Recorder (WithPriority Log ) -> MVar IdeState -> Dynamic -> IO ()
905- runRestartTaskDync recorder ideStateVar dy = runRestartTask recorder ideStateVar (dynShakeRestart dy)
906+ runRestartTaskDyn :: Recorder (WithPriority Log ) -> MVar IdeState -> Dynamic -> IO ()
907+ runRestartTaskDyn recorder ideStateVar dy = runRestartTask recorder ideStateVar (dynShakeRestart dy)
906908
907909runRestartTask :: Recorder (WithPriority Log ) -> MVar IdeState -> ShakeRestartArgs -> IO ()
908910runRestartTask recorder ideStateVar shakeRestartArgs = do
@@ -913,15 +915,15 @@ runRestartTask recorder ideStateVar shakeRestartArgs = do
913915 -- see Note [Housekeeping rule cache and dirty key outside of hls-graph]
914916 atomically $ modifyTVar' (dirtyKeys shakeExtras) $ \ x -> foldl' (flip insertKeySet) x keys
915917 -- Check if there is another restart request pending, if so, we run that one too
916- readAndGo sra sraReStartQueue
917- readAndGo sra sraReStartQueue = do
918- nextRestartArg <- atomically $ tryReadTaskQueue sraReStartQueue
918+ readAndGo sra sraShakeControlQueue
919+ readAndGo sra sraShakeControlQueue = do
920+ nextRestartArg <- atomically $ tryReadTaskQueue sraShakeControlQueue
919921 case nextRestartArg of
920922 Nothing -> return sra
921923 Just (Left dy) -> do
922924 res <- prepareRestart $ dynShakeRestart dy
923925 return $ sra <> res
924- Just (Right _) -> readAndGo sra sraReStartQueue
926+ Just (Right _) -> readAndGo sra sraShakeControlQueue
925927 withMVar'
926928 shakeSession
927929 ( \ runner -> do
0 commit comments