Skip to content
Snippets Groups Projects
Commit 329f7cb9 authored by Ben Gamari's avatar Ben Gamari Committed by Marge Bot
Browse files

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.
parent 4517a382
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment