Commits

Ozgun Ataman  committed 8eabf0e

Reuse live resources instead of always creating new ones

  • Participants
  • Parent commits ccd0135

Comments (0)

Files changed (1)

File Data/Pool.hs

   resource <- liftIO . join . atomically $ do
     ents <- readTVar entries
     case ents of
-      (Entry{..}:es) -> writeTVar entries es >> return create
+      (Entry{..}:es) -> writeTVar entries es >> return (return entry)
       [] -> do
         used <- readTVar inUse
         when (used == maxResources) retry