-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Can we add optional timeout for resource acquiring? Not for creating but taking resource. For now pool waits for available resource infinitely that can be a reason of dead locks.
main :: IO ()
main = do
pool <- newPool PoolConfig
{ createResource = pure 0
, freeResource = const (pure ())
, poolCacheTTL = 60
, poolMaxResources = 3
}
let takeAnd action = withResource pool (const action)
putStrLn "-------------\n 1st\n-------------"
takeAnd do
print 1
takeAnd do
print 2
takeAnd do
print 3
putStrLn "here!"
putStrLn "-------------\n 2nd\n-------------"
takeAnd do
print 1
takeAnd do
print 2
takeAnd do
print 3
takeAnd do
print 4
putStrLn "here!"prints
-------------
1st
-------------
1
2
3
here!
-------------
2nd
-------------
1
2
3
And gets stuck. Of course, it's a user-code bug. But it's better to get exception than get stuck forever
I'm ready to implement it
Znack and yitz-zoomin
Metadata
Metadata
Assignees
Labels
No labels