[Git][ghc/ghc][master] base: Better error message on invalid getSystemTimerManager call

Marge Bot gitlab at gitlab.haskell.org
Tue Sep 1 02:59:21 UTC 2020



 Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
329f7cb9 by Ben Gamari at 2020-08-31T22:59:14-04:00
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.

- - - - -


1 changed file:

- libraries/base/GHC/Event/Thread.hs


Changes:

=====================================
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)



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/329f7cb958551f5b384e2765a823770150152da2

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/329f7cb958551f5b384e2765a823770150152da2
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200831/55e5ba66/attachment.html>


More information about the ghc-commits mailing list