diff options
author | Ben Gamari <ben@smart-cactus.org> | 2020-06-23 18:29:21 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-08-31 22:59:14 -0400 |
commit | 329f7cb958551f5b384e2765a823770150152da2 (patch) | |
tree | c3a685e33aa0bee5fba9483fed00daf9444099e2 | |
parent | 4517a38215eb72a4824c72d97377b9325059bf55 (diff) | |
download | haskell-329f7cb958551f5b384e2765a823770150152da2.tar.gz |
base: Better error message on invalid getSystemTimerManager call
Previously we would produce a rather unhelpful pattern match failure
error in the case where the user called `getSystemTimerManager` in a
program which isn't built with `-threaded`. This understandably confused
the user in #15616.
Fixes #15616.
-rw-r--r-- | libraries/base/GHC/Event/Thread.hs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libraries/base/GHC/Event/Thread.hs b/libraries/base/GHC/Event/Thread.hs index 19b6cd4117..fb40cde4d0 100644 --- a/libraries/base/GHC/Event/Thread.hs +++ b/libraries/base/GHC/Event/Thread.hs @@ -19,6 +19,7 @@ module GHC.Event.Thread import Control.Exception (finally, SomeException, toException) import Data.Foldable (forM_, mapM_, sequence_) import Data.IORef (IORef, newIORef, readIORef, writeIORef) +import Data.Maybe (fromMaybe) import Data.Tuple (snd) import Foreign.C.Error (eBADF, errnoToIOError) import Foreign.C.Types (CInt(..), CUInt(..)) @@ -213,8 +214,9 @@ ioManagerLock = unsafePerformIO $ do getSystemTimerManager :: IO TM.TimerManager getSystemTimerManager = do - Just mgr <- readIORef timerManager - return mgr + fromMaybe err `fmap` readIORef timerManager + where + err = error "GHC.Event.Thread.getSystemTimerManager: the TimerManager requires linking against the threaded runtime" foreign import ccall unsafe "getOrSetSystemTimerThreadEventManagerStore" getOrSetSystemTimerThreadEventManagerStore :: Ptr a -> IO (Ptr a) |