diff --git a/src/Quasar/Async/Fork.hs b/src/Quasar/Async/Fork.hs index 3dfd70e4888b352a6457df48e08f538d684ae648..151c874fcea085040729201fe0f98d51f92cdd75 100644 --- a/src/Quasar/Async/Fork.hs +++ b/src/Quasar/Async/Fork.hs @@ -2,6 +2,8 @@ module Quasar.Async.Fork ( -- * Forking with an asynchronous exception channel -- ** IO + fork, + fork_, forkWithUnmask, forkWithUnmask_, forkFuture, @@ -53,6 +55,12 @@ forkAsyncWithUnmaskSTM fn worker exChan = join <$> startShortIOSTM (unsafeShortI -- * Fork in IO, redirecting errors to an ExceptionSink +fork :: IO () -> ExceptionSink -> IO ThreadId +fork fn exSink = forkWithUnmask ($ fn) exSink + +fork_ :: IO () -> ExceptionSink -> IO () +fork_ fn exSink = void $ fork fn exSink + forkWithUnmask :: ((forall a. IO a -> IO a) -> IO ()) -> ExceptionSink -> IO ThreadId forkWithUnmask fn exChan = mask_ $ forkIOWithUnmask wrappedFn where