goog.structs.Pool
Classgoog.structs.Pool
> goog.Disposable
goog.structs.Pool(opt_minCount, opt_maxCount)
A generic pool class. If min is greater than max, an error is thrown.
opt_minCount
{number
=}
opt_maxCount
{number
=}
.addFreeObject(obj)
Adds an object to the collection of objects that are free. If the object can not be added, then it is disposed.
obj
{Object
}
.addOnDisposeCallback(callback, opt_scope)
Inherited from goog.Disposable
.
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.
callback
{!Function
}
opt_scope
{Object
=}
.adjustForMinMax()
Adjusts the objects held in the pool to be within the min/max constraints. NOTE: It is possible that the number of objects in the pool will still be greater than the maximum count of objects allowed. This will be the case if no more free objects can be disposed of to get below the minimum count (i.e., all objects are in use).
.contains(obj)
Returns true if the given object is in the pool.
obj
{Object
}
boolean
}
.createObject()
Should be overriden by sub-classes to return an instance of the object type that is expected in the pool.
Object
}
.creationStack
{string
}Inherited from goog.Disposable
.
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
.delay
[protected] {number
}The minimum delay between objects being made available, in milliseconds. If this is 0, no minimum delay is enforced.
.dispose()
Inherited from goog.Disposable
.
Disposes of the object. If the object hasn't already been disposed of, calls {@link #disposeInternal}. Classes that extend {@code goog.Disposable} should override {@link #disposeInternal} in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.
void
}
.disposeInternal()
[protected]Disposes of the pool and all objects currently held in the pool.
.disposeObject(obj)
Should be overriden to dispose of an object. Default implementation is to remove all its members, which should render it useless. Calls the object's {@code dispose()} method, if available.
obj
{Object
}
.getCount()
Returns the number of objects currently in the pool.
number
}
.getDisposed
[deprecated]Deprecated. Use {@link #isDisposed} instead.
Inherited from goog.Disposable
.
boolean
}
.getFreeCount()
Returns the number of objects currently free in the pool.
number
}
.getInUseCount()
Returns the number of objects currently in use in the pool.
number
}
.getObject()
Object
|undefined
}
.isDisposed()
Inherited from goog.Disposable
.
boolean
}
.isEmpty()
Determines if the pool contains no objects.
boolean
}
.lastAccess
[protected] {number
?}The time of the last object being made available, in milliseconds since the epoch (i.e., the result of Date#toTime). If this is null, no access has occurred yet.
.objectCanBeReused(obj)
Should be overriden to determine whether an object has become unusable and should not be returned by getObject(). Calls the object's {@code canBeReused()} method, if available.
obj
{Object
}
boolean
}
.registerDisposable(disposable)
Inherited from goog.Disposable
.
Associates a disposable object with this object so that they will be disposed together.
disposable
{goog.disposable.IDisposable
}
.releaseObject(obj)
Returns an object to the pool of available objects so that it can be reused.
obj
{Object
}
boolean
}
.setDelay(delay)
Sets the minimum delay between objects being returned by getObject, in milliseconds. This defaults to zero, meaning that no minimum delay is enforced and objects may be used as soon as they're available.
delay
{number
}
.setMaximumCount(max)
Sets the maximum count of the pool. If max is less than the max count of the pool, an error is thrown.
max
{number
}
.setMinimumCount(min)
Sets the minimum count of the pool. If min is greater than the max count of the pool, an error is thrown.
min
{number
}