Pooled Custom Lifestyle for Windsor that blocks
I have a requirement for a service. The requirement states that I must get up to N instances of a service. If no instances are available block/wait until one is released and then return the available instance. This is very similar to the pooled lifestyle.
My understanding of the Pooled Lifestyle is:
- When first requested N objects will be created (where N is max pool size)
- As requests for the object are received, the pooled lifestyle will initially return an object from the pool, until all the objects in the pool are "in use"
- When all objects are "in use" additional objects (beyond the scope of max pool size) are created.
- As objects are released, they are either destroyed (if there are more than the max pool size) or returned to the pool (if there are fewer than the max pool size).
This is similar to the behavior I want, however with a slight difference. Do not create objects beyond the max pool size, wait for the objects "in use" to be released and then return an available object.
Any ideas? Can this be done without blocking other container开发者_如何学C resolutions on a different thread?
You need to implement a IPoolFactory
and IPool
and register the factory in the container. Then your pool can do whatever you need, including that blocking.
精彩评论