ocaml-multicore / eio

Effects-based direct-style IO for multicore OCaml
Other
548 stars 66 forks source link

Add resource pool #566

Closed darrenldl closed 1 year ago

darrenldl commented 1 year ago

Split from #517 to focus on just resource pool

darrenldl commented 1 year ago

Thanks for feedback! I'll revisit this PR in a few weeks.

talex5 commented 1 year ago

@darrenldl: In #602 I've made a lock-free pool using the Cells module. I think the extra features of this PR (e.g. the monitor fiber) could probably be built on top of that - would that work for your use?

darrenldl commented 1 year ago

@talex5 The monitor is just there to make sure if some acquired resources have become unusable after use or an exception occurred during use, the pool is filled back in. But I think the validate code and exception handling in your run_with fulfills that role already.

I think your version (along with the simpler API) is good - this PR mainly tried to match Lwt pool features, some of which might not be that usable in practice to begin with.

Thanks for adding Eio.Pool!