{-# LANGUAGE CPP, NoImplicitPrelude #-}
{-# LANGUAGE RankNTypes #-}
#if __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE Trustworthy #-}
#endif
module Control.Concurrent.Compat (
module Base
, forkFinally
, forkOSWithUnmask
) where
import Control.Concurrent as Base
#if !(MIN_VERSION_base(4,6,0))
import Control.Exception
#endif
#if !(MIN_VERSION_base(4,9,0))
import GHC.IO (unsafeUnmask)
import Prelude
#endif
#if !(MIN_VERSION_base(4,6,0))
forkFinally :: IO a -> (Either SomeException a -> IO ()) -> IO ThreadId
forkFinally action and_then =
mask $ \restore ->
forkIO $ try (restore action) >>= and_then
#endif
#if !(MIN_VERSION_base(4,9,0))
forkOSWithUnmask :: ((forall a . IO a -> IO a) -> IO ()) -> IO ThreadId
forkOSWithUnmask io = forkOS (io unsafeUnmask)
#endif