eio
eio copied to clipboard
Add Eio.Pool.use ~never_block
This PR adds the optional parameter ?never_block:bool
to Eio.Pool.use
. The default is false
.
Quoting pool.mli
:
If
true
and the pool has reached maximum capacity, then a fresh resource is created to ensure that thisuse
call does not wait for a resource to become available. This resource is immediately disposed after [f x] returns.
In my opinion, this feature makes Eio.Pool
a valid choice for a wider range of use cases.
Method | Availability | Overhead |
---|---|---|
Creating a resource every time | ✅ Never blocks | 🔴 No reuse |
Eio.Pool.use | 🔴 Can block | ✅ Maximal reuse |
Eio.Pool.use ~never_block:true | ✅ Never blocks | 🟡 Some reuse |