packages feed

shelly-extra 0.2 → 0.2.1

raw patch · 2 files changed

+12/−5 lines, 2 files

Files

Shelly/Background.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE OverloadedStrings, ScopedTypeVariables #-} module Shelly.Background (    -- * Running external commands asynchronously.    jobs, background, getBgResult, BgResult@@ -6,6 +6,8 @@  import Shelly import Control.Concurrent+import Control.Exception (finally, catch, throw, SomeException)+import Prelude hiding (catch) import qualified Control.Concurrent.MSem as Sem  -- | Create a 'BgJobManager' that has a 'limit' on the max number of background tasks.@@ -49,9 +51,14 @@     Sem.wait manager     mvar <- newEmptyMVar -- future result +    mainTid <- myThreadId     _<- forkIO $ do-      result <- shelly $ (put state >> proc)-      Sem.signal manager -- open a spot back up-      liftIO $ putMVar mvar result+      result <-+        finally (+            (shelly $ (put state >> proc)) `catch`+              (\(e::SomeException) -> throwTo mainTid e >> throw e)+          )+          (Sem.signal manager >> return ()) -- open a spot back up+      putMVar mvar result     return $ BgResult mvar 
shelly-extra.cabal view
@@ -1,6 +1,6 @@ Name:       shelly-extra -Version:     0.2+Version:     0.2.1 Synopsis:    shelly features that require extra dependencies  Description: Please see the shelly package. Shelly provides a single module for convenient