structs.SimplePool Extends goog.Disposable
A generic pool class. Simpler and more efficient than goog.structs.Pool because it doesn't maintain a list of objects that are in use. This class has constant overhead and doesn't create any additional objects as part of the pool management after construction time. IMPORTANT: If the objects being pooled are arrays or maps that can have unlimited number of properties, they need to be cleaned before being returned to the pool. Also note that {@see goog.object.clean} actually allocates an array to clean the object passed to it, so simply using this function would defy the purpose of using the pool.

Inheritance

Object
     goog.Disposable
          goog.structs.SimplePool

Constructor

goog.structs.SimplePool(initialCountmaxCount)

Parameters

initialCount :
Initial number of objects to populate the free pool at construction time.
maxCount :
Maximum number of objects to keep in the free pool.

Instance Methods

Public Protected Private
createInitial_(initialCount)
Populates the pool with initialCount objects.
Arguments:
initialCount :
The number of objects to add to the pool.
code »
createObject()
Should be overriden by sub-classes to return an instance of the object type that is expected in the pool.
Returns:   The created object.
code »
createObjectFn_()
Function for overriding createObject. The avoids a common case requiring subclassing this class.
code »
disposeInternal()
No description.
code »
disposeObject(obj)
Should be overriden to dispose of an object. Default implementation is to remove all of the object's members, which should render it useless. Calls the object's dispose method, if available.
Arguments:
obj :
The object to dispose.
code »
disposeObjectFn_()
Function for overriding disposeObject. The avoids a common case requiring subclassing this class.
code »
getObject()
Gets a new object from the the pool, if there is one available, otherwise returns null.
Returns:   An object from the pool or a new one if necessary.
code »
releaseObject(obj)
Releases the space in the pool held by a given object -- i.e., remove it from the pool and frees up its space.
Arguments:
obj :
The object to release.
code »
setCreateObjectFn(createObjectFn)
Sets the {@code createObject} function which is used for creating a new object in the pool.
Arguments:
createObjectFn :
Create object function which returns the newly createrd object.
code »
setDisposeObjectFn(disposeObjectFn)
Sets the {@code disposeObject} function which is used for disposing of an object in the pool.
Arguments:
disposeObjectFn :
Dispose object function which takes the object to dispose as a parameter.
code »
dispose()
No description.
code »
disposeInternal()
Deletes or nulls out any references to COM objects, DOM nodes, or other disposable objects. Classes that extend {@code goog.Disposable} should override this method. For example:
mypackage.MyClass = function() {
goog.Disposable.call(this);
// Constructor logic specific to MyClass.
...
};
goog.inherits(mypackage.MyClass, goog.Disposable);

mypackage.MyClass.prototype.disposeInternal = function() {
mypackage.MyClass.superClass_.disposeInternal.call(this);
// Dispose logic specific to MyClass.
...
};
code »
getDisposed()
No description.
Returns:   Whether the object has been disposed of.
code »
isDisposed()
No description.
Returns:   Whether the object has been disposed of.
code »

Instance Properties

disposed_ :
Whether the object has been disposed of.
Code »

Package structs

Package Reference