I need to create channels to other nodes (channels to RabbitMQ nodes which aren't thread safe). I can not create a new channel each time a user sends a message (It is too costly and also RabbitMQ has some limitations for it). So, I decided to create 20 channels and use only them (fixed channels which won't be closed if they are unused for some time). The problem is that I have to write a special queue for it with a special logic but it would be better if there is already a library which can do it.
Here is simple rules which have to be in the queue:
1. When user want to get an object he will get an already created object from the queue.
2. If there is no available object then user will wait till he get an object.
3. If user "A" asked for an object earlier than user "B" then user "B" will get an object only after user "A".
Is there an implementation of such resource pool queue?