There are a few common types of resource object managers, and it just occurred to me today what is the nature of the difference between them. The five types are:
- Object Cache
- Object Factory
- Finite Object Manager
- Object Bank
- Object Pool
The distinction is all about the nature of the resources being managed. A "resource" is a poorly defined term, a situation I'll not attempt to remedy. So I can't say exactly what a resource is, but I can say that "processes use resources to process data in to some final state".
One important distinction between resources is exclusivity. When only a single process is supposed to use a resource t a time then the resource is exclusive. Conversely, a resource that can be used by multiple processes simultaneously is a non-exclusive resource.
Object caches exist to manage non-exclusive resources. Any process can ask a cache for a resource, using some unique identifier, or if the cache's API supports it then some selection criteria. Processes also indicate to the cache when they are done with a resource, so that the cache can create/destroy resource objects according to whatever management strategy it employs.
The other four object managers (factories, banks, finite object managers and pools) exist to manage exclusive resources. Exclusive resource can further be divided along 2 axes: finiteness and expense.
Factories exist to manage infinite, cheap resources: resource objects which are not significantly effected by the number of allocated peer resource objects, and which are not considered expensive to create/allocate. Factories exist to assist client procedures with the creation and/or destruction of these cheap resource objects.
When an exclusive resource is infinite, but relatively expensive to create/allocate, then an Object Bank is often the most appropriate object manager. A bank has an API designed for multiple client processes to create and Store resource objects for later retrieval. The whole point is to avoid unnecessary creation/destruction of objects since they are expensive to create. But a bank makes no attempt to re-use resource objects between client processes, preferring availability of exclusive resource objects over reducing the raw number of allocated resource objects (since the resource is infinite).
A finite object manager exists to manage resource objects that are very cheap to create/allocate, but which represent a finite resource. The finite object manager suspends client processes that request resources and possibly assigns some priority to client processes when the supply of finite resources is depleated. The finite object manager prefers destruction and re-allocation instead of resource object re-use, since resources are supposed to be cheap to create/allocate.
Finally, an Object Pool exists to manager a finite, expensive resource. The pool resists creation/destruction of resource objects by managing resource re-use between client processes. The pool also suspends client processes when the pooled resource is depleated.
Note that the term "pool" is often used to refer on finite object managers and object banks, but really there are fundamental differences between these types of managers; differences in
- How the target resource object's lifetime is managed
- The manager's API design
- Peformance characteristics and how the manager would be tuned for optimization
So use of the term "pool" to refer to all three types of managers can really hinder development and optimization efforts.
9:36:43 AM
|