[commit: ghc] master: base: Add forkOSWithUnmask (dec5cd4)

git at git.haskell.org git at git.haskell.org
Tue Oct 13 06:09:55 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/dec5cd4085488686b5ed50bb26ccbc0ba7b645ec/ghc

>---------------------------------------------------------------

commit dec5cd4085488686b5ed50bb26ccbc0ba7b645ec
Author: Joey Adams <joeyadams3.14159 at gmail.com>
Date:   Fri Jun 21 23:19:34 2013 -0400

    base: Add forkOSWithUnmask
    
    Fixes #8010, according to the specified libraries proposal. [1]
    
    Also, some minor wordsmithing.
    
      [1] http://thread.gmane.org/gmane.comp.lang.haskell.libraries/22709
    
    Signed-off-by: Austin Seipp <austin at well-typed.com>


>---------------------------------------------------------------

dec5cd4085488686b5ed50bb26ccbc0ba7b645ec
 libraries/base/Control/Concurrent.hs | 9 ++++++++-
 libraries/base/changelog.md          | 6 +++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/libraries/base/Control/Concurrent.hs b/libraries/base/Control/Concurrent.hs
index 35248bf..1786c3d 100644
--- a/libraries/base/Control/Concurrent.hs
+++ b/libraries/base/Control/Concurrent.hs
@@ -3,6 +3,7 @@
            , MagicHash
            , UnboxedTuples
            , ScopedTypeVariables
+           , RankNTypes
   #-}
 {-# OPTIONS_GHC -fno-warn-deprecations #-}
 -- kludge for the Control.Concurrent.QSem, Control.Concurrent.QSemN
@@ -73,6 +74,7 @@ module Control.Concurrent (
         -- $boundthreads
         rtsSupportsBoundThreads,
         forkOS,
+        forkOSWithUnmask,
         isCurrentThreadBound,
         runInBoundThread,
         runInUnboundThread,
@@ -180,7 +182,7 @@ attribute will block all other threads.
 
 -}
 
--- | fork a thread and call the supplied function when the thread is about
+-- | Fork a thread and call the supplied function when the thread is about
 -- to terminate, with an exception or a returned value.  The function is
 -- called with asynchronous exceptions masked.
 --
@@ -316,6 +318,11 @@ forkOS action0
         return tid
     | otherwise = failNonThreaded
 
+-- | Like 'forkIOWithUnmask', but the child thread is a bound thread,
+-- as with 'forkOS'.
+forkOSWithUnmask :: ((forall a . IO a -> IO a) -> IO ()) -> IO ThreadId
+forkOSWithUnmask io = forkOS (io unsafeUnmask)
+
 -- | Returns 'True' if the calling thread is /bound/, that is, if it is
 -- safe to use foreign libraries that rely on thread-local state from the
 -- calling thread.
diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md
index 7c4bf77..24a6e7f 100644
--- a/libraries/base/changelog.md
+++ b/libraries/base/changelog.md
@@ -67,7 +67,11 @@
     unlifted types (#10868)
 
   * Keep `shift{L,R}` on `Integer` with negative shift-arguments from
-	segfaulting (#10571)
+    segfaulting (#10571)
+
+  * Add `forkOSWithUnmask` to `Control.Concurrent`, which is like
+    `forkIOWithUnmask`, but the child is run in a bound thread.
+
 
 ## 4.8.1.0  *Jul 2015*
 



More information about the ghc-commits mailing list