Content deleted Content added
Attemped merge of object cesspool |
dereferenced means following a pointer; not there are no more references |
||
Line 1:
In [[computer programming]], an '''object pool''' is a construct of objects which can be used concurrently. Typically,
If no objects are available in the pool, a new object is created and returned to the pool when it
This contruct is typically employed in software in situations where instantiating an object is prohibitively expensive, or the object itself uses a significant amount of resources and must be controlled in a fixed pool size.
When writing an object pool, the programmer has to be careful to make sure the state of the objects returned to the pool is reset back to a useable state for the next use of the object. Often if this is not observed, the object will be in some state that was unexpected by the client program and that will cause the client program to fail.
The presence of stale state is not always an issue; it becomes dangerous when the presence of stale state causes the object to behave differently. For example, an object that represents authentication details may break if the "successfully authenticated" flag is not reset before it is passed out; however, it will work just fine if you fail to reset the identity of the last authentication server used. Generally, this problem is avoided by amending the objects in the pool to include a "reset state" method, which is called just before the object is handed out and which resets any dangerous state to the construction defaults.
|