[Git][ghc/ghc][wip/T15616] base: Better error message on invalid getSystemTimerManager call
Ben Gamari
gitlab at gitlab.haskell.org
Wed Jun 24 18:55:15 UTC 2020
Ben Gamari pushed to branch wip/T15616 at Glasgow Haskell Compiler / GHC
Commits:
190d8073 by Ben Gamari at 2020-06-24T14:55:05-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 <$> 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/190d807374ac48d76cf0ab4fec57d54c229cbf7b
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/190d807374ac48d76cf0ab4fec57d54c229cbf7b
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/20200624/42cb391d/attachment-0001.html>
More information about the ghc-commits
mailing list