Commits

basvandijk  committed 0841c30

Use controlIO directly instead of Control.Exception.Control.onException
This should be slightly more efficient in case an exception is thrown
because the exception handler is already an IO computation.

  • Participants
  • Parent commits a8ee9af

Comments (0)

Files changed (1)

File Data/Pool.hs

 import Control.Applicative ((<$>))
 import Control.Concurrent (forkIO, killThread, myThreadId, threadDelay)
 import Control.Concurrent.STM
-import Control.Exception (SomeException, catch)
-import Control.Exception.Control (onException)
+import Control.Exception (SomeException, catch, onException)
 import Control.Monad (forM_, forever, join, liftM2, unless, when)
 import Control.Monad.IO.Class (liftIO)
-import Control.Monad.IO.Control (MonadControlIO)
+import Control.Monad.IO.Control (MonadControlIO, controlIO)
 import Data.Hashable (hash)
 import Data.List (partition)
 import Data.Time.Clock (NominalDiffTime, UTCTime, diffUTCTime, getCurrentTime)
         writeTVar inUse $! used + 1
         return $
           create `onException` atomically (modifyTVar_ inUse (subtract 1))
-  ret <- act resource `onException` (liftIO $ do
+  ret <- controlIO $ \runInIO -> runInIO (act resource) `onException` (do
            destroy resource `catch` \(_::SomeException) -> return ()
            atomically (modifyTVar_ inUse (subtract 1)))
   liftIO $ do