scrive / pool

A high-performance striped resource pooling implementation for Haskell
Other
18 stars 11 forks source link

Don't exceed maximum resources #16

Open parsonsmatt opened 1 year ago

parsonsmatt commented 1 year ago

This PR builds on #15

Fixes #13

This PR has two main behavior changes:

  1. If numStripes is greater than maxResources, then we only create maxResources of stripes, each receiving a single resource.
  2. If numStripes does not evenly divide maxResources, then resources are divided among stripes such that no stripe has two more resources than any other stripe.

With these two changes, poolMaxResources is guaranteed to be a true maximum of resources.

fumieval commented 1 year ago

@arybczak any chance to have a look at this?