spawn 0.1 → 0.2
raw patch · 2 files changed
+15/−4 lines, 2 files
Files
- Control/Concurrent/Spawn.hs +14/−3
- spawn.cabal +1/−1
Control/Concurrent/Spawn.hs view
@@ -1,10 +1,13 @@-module Control.Concurrent.Spawn(- -- * Spawn +module Control.Concurrent.Spawn+ ( -- * Spawn spawn -- * Spawn with @'try'@ , Result- , spawnTry) where+ , spawnTry+ + -- * Limiting concurrency+ , pool ) where import Control.Concurrent import Control.Exception@@ -30,3 +33,11 @@ spawn m = do r <- spawnTry m return (r >>= either throwIO return)++-- | Given /n/, produces a function to wrap @'IO'@ actions.+-- No more than /n/ wrapped actions will be in progress at+-- one time.+pool :: Int -> IO (IO a -> IO a)+pool n = do+ s <- newQSem n+ return $ bracket_ (waitQSem s) (signalQSem s)
spawn.cabal view
@@ -1,5 +1,5 @@ name: spawn-version: 0.1+version: 0.2 license: BSD3 license-file: LICENSE synopsis: Tiny library for joinable computations / threads with results.