steinwurf / recycle

Simple resource pool for recycling resources in C++
BSD 3-Clause "New" or "Revised" License
63 stars 23 forks source link

allocate limit #19

Closed mipac closed 6 years ago

mipac commented 6 years ago

Hi,

how can I add a finite size to the pool? pool.allocate should have a "timed" overload, to wait for a freed resource when the limit is reached

mortenvp commented 6 years ago

Hi @mipac interesting suggestions. Currently the pool does not support the features you request. However, I think it should be possible to add the features you are thinking about - by adding logic to the allocator function. I.e. you can use a custom allocator which will check for both the current size of the pool and wait for resources if non are available.

Although the waiting part would require some threading which I'm guessing should be ok, if you use a lock policy. But, if you run into problems we can try to take a look.

mortenvp commented 6 years ago

I'm closing this issue, but feel free to re-open or open a new one with additional questions.

mipac commented 6 years ago

thx a lot for your answer I'll give a try sure it's possible, but I'm not sure to produce a code as elegant as yours!