eio icon indicating copy to clipboard operation
eio copied to clipboard

Add Eio.Pool.use ~never_block

Open SGrondin opened this issue 6 months ago • 0 comments

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 this use 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

SGrondin avatar Dec 16 '23 18:12 SGrondin