@@ -154,7 +154,8 @@ import Development.IDE.Graph.Database (ShakeDatabase,
154154import Development.IDE.Graph.Internal.Action (runActionInDbCb )
155155import Development.IDE.Graph.Internal.Database (AsyncParentKill (AsyncParentKill ))
156156import Development.IDE.Graph.Internal.Types (DBQue , Step (.. ),
157- getShakeStep )
157+ getShakeStep ,
158+ shakeDataBaseQueue )
158159import Development.IDE.Graph.Rule
159160import Development.IDE.Types.Action
160161import Development.IDE.Types.Diagnostics
@@ -858,14 +859,13 @@ delayedAction a = do
858859
859860
860861data ShakeRestartArgs = ShakeRestartArgs
861- { sraVfs :: ! VFSModified
862- , sraReason :: ! String
863- , sraActions :: ! [DelayedAction () ]
864- , sraBetweenSessions :: IO [Key ]
865- , sraShakeControlQueue :: ! ShakeControlQueue
866- , sraCount :: ! Int
867- , sraWaitMVars :: ! [MVar () ]
862+ { sraVfs :: ! VFSModified
863+ , sraReason :: ! String
864+ , sraActions :: ! [DelayedAction () ]
865+ , sraBetweenSessions :: IO [Key ]
866+ , sraCount :: ! Int
868867 -- ^ Just for debugging, how many restarts have been requested so far
868+ , sraWaitMVars :: ! [MVar () ]
869869 }
870870
871871instance Show ShakeRestartArgs where
@@ -881,7 +881,6 @@ instance Semigroup ShakeRestartArgs where
881881 , sraReason = sraReason a ++ " ; " ++ sraReason b
882882 , sraActions = sraActions a ++ sraActions b
883883 , sraBetweenSessions = (++) <$> sraBetweenSessions a <*> sraBetweenSessions b
884- , sraShakeControlQueue = sraShakeControlQueue a
885884 , sraCount = sraCount a + sraCount b
886885 , sraWaitMVars = sraWaitMVars a ++ sraWaitMVars b
887886 }
@@ -895,7 +894,7 @@ shakeRestart rts vfs reason acts ioActionBetweenShakeSession = do
895894 -- submit at the head of the queue,
896895 -- prefer restart request over any pending actions
897896 void $ submitWorkAtHead rts $ Left $
898- toDyn $ ShakeRestartArgs vfs reason acts ioActionBetweenShakeSession rts 1 [waitMVar]
897+ toDyn $ ShakeRestartArgs vfs reason acts ioActionBetweenShakeSession 1 [waitMVar]
899898 -- Wait until the restart is done
900899 takeMVar waitMVar
901900
@@ -911,21 +910,23 @@ dynShakeRestart dy = case fromDynamic dy of
911910runRestartTask :: Recorder (WithPriority Log ) -> MVar IdeState -> ShakeRestartArgs -> IO ()
912911runRestartTask recorder ideStateVar shakeRestartArgs = do
913912 IdeState {shakeDb, shakeSession, shakeExtras, shakeDatabaseProfile} <- readMVar ideStateVar
913+ let shakeControlQueue = shakeDataBaseQueue shakeDb
914914 let prepareRestart sra@ ShakeRestartArgs {.. } = do
915915 keys <- sraBetweenSessions
916916 -- it is every important to update the dirty keys after we enter the critical section
917917 -- see Note [Housekeeping rule cache and dirty key outside of hls-graph]
918918 atomically $ modifyTVar' (dirtyKeys shakeExtras) $ \ x -> foldl' (flip insertKeySet) x keys
919+ sleep 0.2
919920 -- Check if there is another restart request pending, if so, we run that one too
920- readAndGo sra sraShakeControlQueue
921- readAndGo sra sraShakeControlQueue = do
922- nextRestartArg <- atomically $ tryReadTaskQueue sraShakeControlQueue
921+ readAndGo sra
922+ readAndGo sra = do
923+ nextRestartArg <- atomically $ tryReadTaskQueue shakeControlQueue
923924 case nextRestartArg of
924925 Nothing -> return sra
925926 Just (Left dy) -> do
926927 res <- prepareRestart $ dynShakeRestart dy
927928 return $ sra <> res
928- Just (Right _) -> readAndGo sra sraShakeControlQueue
929+ Just (Right _) -> readAndGo sra
929930 withMVar'
930931 shakeSession
931932 ( \ runner -> do
@@ -1049,7 +1050,7 @@ newSession recorder extras@ShakeExtras{..} vfsMod shakeDb acts reason = do
10491050 parentTid <- myThreadId
10501051 workThread <- asyncWithUnmask $ \ x -> do
10511052 childThreadId <- myThreadId
1052- logWith recorder Info $ LogShakeText (" Starting shake thread: " <> T. pack (show childThreadId) <> " (parent: " <> T. pack (show parentTid) <> " )" )
1053+ -- logWith recorder Info $ LogShakeText ("shake thread: " <> T.pack (show childThreadId) <> " (parent: " <> T.pack (show parentTid) <> ")")
10531054 workRun start x
10541055
10551056 -- Cancelling is required to flush the Shake database when either
0 commit comments