packages feed

concurrent-extra 0.3 → 0.3.1

raw patch · 2 files changed

+16/−8 lines, 2 filesnew-uploaderPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Control.Concurrent.Thread: unsafeWait :: ThreadId α -> IO α

Files

Control/Concurrent/Thread.hs view
@@ -33,9 +33,12 @@   , wait   , waitTimeout   , isRunning++    -- * Convenience functions   , killThread   , killThreadTimeout   , throwTo+  , unsafeWait   ) where  @@ -45,14 +48,14 @@  -- from base: import Control.Applicative ( (<$>) )-import Control.Exception   ( Exception, SomeException+import Control.Exception   ( Exception, SomeException(SomeException)                            , AsyncException(ThreadKilled)-                           , catch, block, unblock+                           , try, blocked, block, unblock, throwIO                            ) import Control.Monad       ( return, (>>=), fail, (>>), fmap ) import Data.Bool           ( Bool(..) ) import Data.Eq             ( Eq, (==) )-import Data.Either         ( Either(Left, Right) )+import Data.Either         ( Either, either ) import Data.Function       ( ($), on ) import Data.Maybe          ( Maybe(..), isNothing, isJust ) import Data.Ord            ( Ord, compare )@@ -93,7 +96,7 @@ data ThreadId α = ThreadId     { stopped   ∷ Broadcast (Either SomeException α)       -- | Extract the underlying 'Conc.ThreadId'-      -- (Conctrol.Concurrent.ThreadId).+      -- (@Conctrol.Concurrent.ThreadId@).     , threadId  ∷ Conc.ThreadId     } deriving Typeable @@ -113,9 +116,9 @@ fork ∷ (IO () → IO Conc.ThreadId) → IO α → IO (ThreadId α) fork doFork a = do   stop ← Broadcast.new-  tid ← block $ doFork $ let writeStop = Broadcast.write stop-                         in catch (unblock a >>= writeStop ∘ Right)-                                                (writeStop ∘ Left)+  b ← blocked+  tid ← block $ doFork $ try (if b then a else unblock a) >>=+                         Broadcast.write stop   return $ ThreadId stop tid  {-|@@ -188,6 +191,7 @@ isRunning ∷ ThreadId α → IO Bool isRunning = fmap isNothing ∘ Broadcast.tryRead ∘ stopped + ------------------------------------------------------------------------------- -- Convenience functions -------------------------------------------------------------------------------@@ -248,6 +252,10 @@ -} throwTo ∷ Exception e ⇒ ThreadId α → e → IO () throwTo = Conc.throwTo ∘ threadId++-- |Like 'wait' but will rethrow the exception that was thrown in target thread.+unsafeWait ∷ ThreadId α → IO α+unsafeWait tid = wait tid >>= either (\(SomeException e) → throwIO e) return   -- The End ---------------------------------------------------------------------
concurrent-extra.cabal view
@@ -1,5 +1,5 @@ name:          concurrent-extra-version:       0.3+version:       0.3.1 cabal-version: >= 1.6 build-type:    Custom stability:     experimental