Origin: |
Grand 98 |
Reason: |
Allows clients to re-use objects
rather than to discard and later re-create them.
|
Synopsis: |
Define a wrapper class, the Object Pool,
around the construction of reusable objects.
The class accepts from clients returned used objects
and returns them to clients instead of new objects.
|
Example: |
Database connections may be expensive to create.
An Object Pool stores used connections when
no longer needed and returns them when a new connection is required.
|
Solution: |
Reusable |
Class of the reusable objects managed by the ReusablePool. |
Database connection |
Client |
Class that uses the Reusable objects. |
Database client |
ReusablePool |
Class that manages the Reusable objects. |
|
|
See also: |
CacheManagement
|
Note: |
An ObjectPool object is generally a
Singleton
and manages one type only of objects.
|