packages feed

unsafe-promises 0.0.1.2 → 0.0.1.3

raw patch · 2 files changed

+15/−5 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Control/Concurrent/Promise/Unsafe.hs view
@@ -18,9 +18,10 @@        ) where  import Control.Concurrent.Thread (forkIO, Result, result)-import Control.Concurrent.Chan (Chan, newChan, writeChan, -                                getChanContents)+import Control.Concurrent.Chan (Chan, newChan, readChan, writeChan) import Control.Exception (catch)+import GHC.Conc (pseq)+import System.IO.Unsafe (unsafeInterleaveIO)  import Control.Monad import Control.Applicative@@ -46,14 +47,23 @@ tryPromise :: IO a -> IO (Result a) tryPromise io = head <$> tryPromises [io] + -- |Forks a sequence of IO computations in multiple threads, and immediately -- returns a list of futures. The order of the futures is determined by -- the order in which the threads terminate. If an exception is thrown by the -- list of threads, then the exception is re-thrown when its corresponding -- future is evaluated. promises :: [IO a] -> IO [a]-promises ios = mapM result =<< getChanContents =<< safePromises ios+promises ios = do+  c <- safePromises ios+  fmap (scanl1 pseq) . forM ios $ \_ -> unsafeInterleaveIO (result =<< readChan c)+{-# NOINLINE promises #-} + -- |Like 'promises', but doesn't re-throw exceptions. tryPromises :: [IO a] -> IO [Result a]-tryPromises ios = getChanContents =<< safePromises ios+tryPromises ios = do+  c <- safePromises ios+  fmap (scanl1 pseq) . forM ios +    $ \_ -> unsafeInterleaveIO (readChan c)+{-# NOINLINE tryPromises #-}
unsafe-promises.cabal view
@@ -1,5 +1,5 @@ Name: unsafe-promises-Version: 0.0.1.2+Version: 0.0.1.3 Cabal-Version: >= 1.6 License: BSD3 License-File: LICENSE