unsafe-promises 0.0.1.1 → 0.0.1.2
raw patch · 2 files changed
+5/−15 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
Control/Concurrent/Promise/Unsafe.hs view
@@ -18,10 +18,9 @@ ) where import Control.Concurrent.Thread (forkIO, Result, result)-import Control.Concurrent.Chan (Chan, newChan, readChan, writeChan)+import Control.Concurrent.Chan (Chan, newChan, writeChan, + getChanContents) import Control.Exception (catch)-import GHC.Conc (pseq)-import System.IO.Unsafe (unsafeInterleaveIO) import Control.Monad import Control.Applicative@@ -47,23 +46,14 @@ 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 = do- c <- safePromises ios- fmap (scanl1 pseq) . forM ios $ \_ -> unsafeInterleaveIO (result =<< readChan c)-{-# NOINLINE promises #-}-+promises ios = mapM result =<< getChanContents =<< safePromises ios -- |Like 'promises', but doesn't re-throw exceptions. tryPromises :: [IO a] -> IO [Result a]-tryPromises ios = do- c <- safePromises ios- fmap (scanl1 pseq) . forM ios - $ \_ -> unsafeInterleaveIO (readChan c)-{-# NOINLINE tryPromises #-}+tryPromises ios = getChanContents =<< safePromises ios
unsafe-promises.cabal view
@@ -1,5 +1,5 @@ Name: unsafe-promises-Version: 0.0.1.1+Version: 0.0.1.2 Cabal-Version: >= 1.6 License: BSD3 License-File: LICENSE