packages feed

pooled-io 0.0 → 0.0.0.1

raw patch · 5 files changed

+30/−15 lines, 5 filesdep ~transformers

Dependency ranges changed: transformers

Files

pooled-io.cabal view
@@ -1,5 +1,5 @@ Name:             pooled-io-Version:          0.0+Version:          0.0.0.1 License:          BSD3 License-File:     LICENSE Author:           Henning Thielemann <haskell@henning-thielemann.de>@@ -15,7 +15,7 @@   the Haskell program was started with,   i.e. the number after the RTS option @-N@.   .-  There some flavors of this functionality:+  There are some flavors of this functionality:   .   * "Control.Concurrent.PooledIO.Independent":     run independent actions without results in parallel@@ -38,7 +38,7 @@   default:     False  Source-Repository this-  Tag:         0.0+  Tag:         0.0.0.1   Type:        darcs   Location:    http://code.haskell.org/~thielema/pooled-io/ @@ -48,7 +48,7 @@  Library   Build-Depends:-    transformers >=0.2.2 && <0.4,+    transformers >=0.2.2 && <0.5,     deepseq >=1.3 && <1.4,     unsafe >=0.0 && <0.1,     utility-ht >=0.0.9 && <0.1,
src/Control/Concurrent/PooledIO/Final.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE Safe #-} {- | This module implements something similar to "Control.Concurrent.PooledIO.InOrder",@@ -13,12 +13,18 @@ import Control.DeepSeq (NFData)  import Control.Monad (join)-import Control.Applicative (Applicative)+import Control.Applicative (Applicative, pure, (<*>)) import Data.Functor.Compose (Compose(Compose))   newtype T a = Cons (Compose Pool.T IO a)-   deriving (Functor, Applicative)++instance Functor T where+   fmap f (Cons m) = Cons $ fmap f m++instance Applicative T where+   pure = Cons . pure+   Cons f <*> Cons a = Cons $ f <*> a   {- |
src/Control/Concurrent/PooledIO/InOrder.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE GeneralizedNewtypeDeriving #-} module Control.Concurrent.PooledIO.InOrder (    T, run, runLimited, fork,    ) where@@ -9,11 +8,21 @@ import qualified System.Unsafe as Unsafe  import Control.Monad.IO.Class (MonadIO, liftIO)-import Control.Applicative (Applicative)+import Control.Applicative (Applicative, pure, (<*>))  -newtype T a = Cons (Pool.T a)-   deriving (Functor, Applicative, Monad)+newtype T a = Cons {decons :: Pool.T a}++instance Functor T where+   fmap f (Cons m) = Cons $ fmap f m++instance Applicative T where+   pure = Cons . pure+   Cons f <*> Cons a = Cons $ f <*> a++instance Monad T where+   return = Cons . return+   Cons x >>= k  =  Cons $ decons . k =<< x  {- The 'complete' MVar makes sure
src/Control/Concurrent/PooledIO/Independent.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE Safe #-} module Control.Concurrent.PooledIO.Independent (    run,    runLimited,
src/Control/Concurrent/PooledIO/Monad.hs view
@@ -1,8 +1,9 @@+{-# LANGUAGE Safe #-} module Control.Concurrent.PooledIO.Monad where  import Control.Concurrent.MVar (MVar, newEmptyMVar, takeMVar, putMVar) import Control.Concurrent (forkIO, getNumCapabilities)-import Control.DeepSeq (NFData, deepseq)+import Control.DeepSeq (NFData, ($!!)) import Control.Exception (finally)  import qualified Control.Monad.Trans.State as MS@@ -26,9 +27,7 @@      else liftIO $ takeMVar complete    liftIO $ do       result <- newEmptyMVar-      forkFinally complete $ do-         r <- act-         deepseq r $ putMVar result r+      forkFinally complete $ (putMVar result $!!) =<< act       return $ takeMVar result  forkFinally :: MVar () -> IO () -> IO ()