-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Labels
bugSomething isn't workingSomething isn't working
Description
scala> val p = IO.ref(0).flatMap(ref =>
| KeyPool.Builder((i: Int) => Resource.make(ref.update(_ + 1).as(i))(i => IO.println(s"kill $i") *> ref.update(_ - 1)))
| .withMaxTotal(5)
| .withMaxIdle(5)
| .build.use{ keypool =>
| keypool.take(0).replicateA(5).use(_ => ref.get.flatMap(i => IO.println(s"total $i"))) *>
| keypool.take(1).replicateA(5).use(_ => ref.get.flatMap(i => IO.println(s"total $i"))) *>
| IO.println("DONE") *>
| ref.get
| }
| )
val p: cats.effect.IO[Int] = IO(...)
scala> p.unsafeRunSync()
total 5
total 10
kill 1
kill 1
kill 1
kill 1
DONE
kill 0
kill 0
kill 0
kill 0
kill 0
kill 1
val res29: Int = 6
As you can see, at one point 10 resources are allocated, while the max is set to 5. At the end there are still 6 which might be a separate issue...
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working