#4858: Add Control.Concurrent.forkIOWithUnmask, deprecate forkIOUnmasked
---------------------------------+------------------------------------------
    Reporter:  simonmar          |        Owner:              
        Type:  proposal          |       Status:  new         
    Priority:  normal            |    Milestone:              
   Component:  libraries/base    |      Version:  7.0.1       
    Keywords:                    |     Testcase:              
   Blockedby:                    |   Difficulty:              
          Os:  Unknown/Multiple  |     Blocking:              
Architecture:  Unknown/Multiple  |      Failure:  None/Unknown
---------------------------------+------------------------------------------
Description changed by simonmar:

Old description:

> We added `forkIOUnmasked` as part of the new asynchronous exceptions API
> in base 4.3.0.0 (GHC 7.0.1).  Unfortunately, `forkIOUnmasked` isn't very
> useful: the computation in the child thread is executed in the unmasked
> state, so the child doesn't have a way to reliably set up an exception
> handler before an asynchronous exception is raised.
>
> This proposal is to replace `forkIOUnmasked` with `forkIOWithUnmask`:
>
> {{{
> -- | Like 'forkIO', but the child thread is passed a function that can
> -- be used to unmask asynchronous exceptions.  This function is
> -- typically used in the following way
> --
> -- >  ... mask_ $ forkIOWithUnmask $ \unmask ->
> -- >                 catch (unmask ...) handler
> --
> -- so that the exception handler in the child thread is established
> -- with asynchronous exceptions masked, meanwhile the main body of
> -- the child thread is executed in the unmasked state.
> --
> -- Note that the unmask function passed to the child thread should
> -- only be used in that thread; the behaviour is undefined if it is
> -- invoked in a different thread.
> --
> forkIOWithUnmask :: ((forall a . IO a -> IO a) -> IO ()) -> IO ThreadId
> forkIOWithUnmask io = forkIO (io unsafeUnmask)
> }}}
>
> `forkIOUnmasked` will be deprecated.
>
> Some discussion leading up to this can be found in #3837.

New description:

 We added `forkIOUnmasked` as part of the new asynchronous exceptions API
 in base 4.3.0.0 (GHC 7.0.1).  Unfortunately, `forkIOUnmasked` isn't very
 useful: the computation in the child thread is executed in the unmasked
 state, so the child doesn't have a way to reliably set up an exception
 handler before an asynchronous exception is raised.

 This proposal is to replace `forkIOUnmasked` with `forkIOWithUnmask`:

 {{{
 -- | Like 'forkIO', but the child thread is passed a function that can
 -- be used to unmask asynchronous exceptions.  This function is
 -- typically used in the following way
 --
 -- >  ... mask_ $ forkIOWithUnmask $ \unmask ->
 -- >                 catch (unmask ...) handler
 --
 -- so that the exception handler in the child thread is established
 -- with asynchronous exceptions masked, meanwhile the main body of
 -- the child thread is executed in the unmasked state.
 --
 -- Note that the unmask function passed to the child thread should
 -- only be used in that thread; the behaviour is undefined if it is
 -- invoked in a different thread.
 --
 forkIOWithUnmask :: ((forall a . IO a -> IO a) -> IO ()) -> IO ThreadId
 forkIOWithUnmask io = forkIO (io unsafeUnmask)
 }}}

 `forkIOUnmasked` will be deprecated.

 Some discussion leading up to this can be found in #3837.

 Discussion period: 3 weeks (until 12 Jan 2011)

--

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4858#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to