Skip to content

Commit e4fd853

Browse files
committed
use takeMVar
1 parent 84e6731 commit e4fd853

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

ghcide/src/Development/IDE/Core/Shake.hs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ module Development.IDE.Core.Shake(
7575
VFSModified(..), getClientConfigAction,
7676
) where
7777

78-
import Control.Concurrent (withMVar)
78+
import Control.Concurrent (takeMVar, withMVar)
7979
import Control.Concurrent.Async
8080
import Control.Concurrent.STM
8181
import Control.Concurrent.STM.Stats (atomicallyNamed)
@@ -729,16 +729,17 @@ shakeSessionInit recorder ide@IdeState{..} = do
729729

730730
shakeShut :: Recorder (WithPriority Log) -> IdeState -> IO ()
731731
shakeShut recorder IdeState{..} = do
732-
res <- timeout 1 $ withMVar shakeSession $ \runner -> do
733-
-- Shake gets unhappy if you try to close when there is a running
734-
-- request so we first abort that.
735-
cancelShakeSession runner
736-
void $ shakeDatabaseProfile shakeDb
737-
progressStop $ progress shakeExtras
738-
stopMonitoring
732+
res <- timeout 1 $ takeMVar shakeSession
739733
case res of
734+
Just session -> do
735+
-- Shake gets unhappy if you try to close when there is a running
736+
-- request so we first abort that.
737+
cancelShakeSession session
738+
void $ shakeDatabaseProfile shakeDb
739+
progressStop $ progress shakeExtras
740+
stopMonitoring
741+
case res of
740742
Nothing -> logWith recorder Error $ LogTimeOutShuttingDownWaitForSessionVar 1
741-
Just _ -> pure ()
742743

743744

744745
-- | This is a variant of withMVar where the first argument is run unmasked and if it throws

0 commit comments

Comments
 (0)