AV
createMinPool Config{..} alloc free = do
cnt <- newIORef 0
mdo
let wrappedAlloc = mask_ (alloc >>= \x -> modifyIORef' cnt succ >> pure x)
wrappedFree x = free x finally modifyIORef' cnt pred finally (restart pool cnt)
pool <- createPool
wrappedAlloc
wrappedFree
configStripes
(realToFrac configIdleTime)
(configResourcePerStripe)
pure pool
where
configMinResources = 5
restart pool cnt = mask_ $ do
n <- readIORef cnt
when (n < configMinResources) $
withResourceLimited pool (const $ pure ())
а придумайте пару причин почему это не взлетит?// то что нужно делать хитрый destroyPool не в счёт
