goog.structs.PriorityPool<VALUE>
Provided By | |
---|---|
Extends | |
All Implemented Interfaces | |
All Known Direct Subclasses |
A generic pool class. If min is greater than max, an error is thrown.
new PriorityPool<VALUE>( opt_minCount, opt_maxCount )
Parameters |
|
---|
Instance Methods
this.addFreeObject( obj ) → void
void
Adds an object to the collection of objects that are free. If the object can not be added, then it is disposed.
NOTE: This method does not remove the object from the in use collection.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.addOnDisposeCallback<T>( callback, opt_scope ) → void
void
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added. If a callback is added to an already disposed Disposable, it will be called immediately.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.adjustForMinMax() → void
void
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).
Overrides | |
---|---|
Parameters | None. |
this.contains( obj ) → boolean
boolean
Returns true if the given object is in the pool.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.createObject() → VALUE
VALUE
Should be overridden by sub-classes to return an instance of the object type that is expected in the pool.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.dispose() → ?
?
Disposes of the object and its resources.
Overrides | ||
---|---|---|
Specified by | ||
Parameters | None. | |
Returns |
|
this.disposeInternal() → void
void
Disposes of the pool and all objects currently held in the pool.
Overrides | |
---|---|
Parameters | None. |
this.disposeObject( obj ) → void
void
Should be overridden to dispose of an object. Default implementation is to
remove all its members, which should render it useless. Calls the object's
dispose()
method, if available.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.getCount() → number
number
Returns the number of objects currently in the pool.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getDisposed() → boolean
boolean
warning Deprecated | Use |
---|
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getFreeCount() → number
number
Returns the number of objects currently free in the pool.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getInUseCount() → number
number
Returns the number of objects currently in use in the pool.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getObject( opt_callback, opt_priority ) → ?
?
Get a new object from the pool, if there is one available, otherwise return undefined.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
| ||||||||
Returns |
|
this.isDisposed() → boolean
boolean
Overrides | |||
---|---|---|---|
Specified by | |||
Parameters | None. | ||
Returns |
|
this.isEmpty() → boolean
boolean
Determines if the pool contains no objects.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.objectCanBeReused( obj ) → boolean
boolean
Should be overridden to determine whether an object has become unusable and
should not be returned by getObject(). Calls the object's
canBeReused()
method, if available.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.registerDisposable( disposable ) → void
void
Associates a disposable object with this object so that they will be disposed together.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.releaseObject( obj ) → boolean
boolean
Returns an object to the pool of available objects so that it can be reused.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.setDelay( delay ) → void
void
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.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.setMaximumCount( max ) → void
void
Sets the maximum count of the pool. If max is less than the min count of the pool, an error is thrown.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setMinimumCount( min ) → void
void
Sets the minimum count of the pool. If min is greater than the max count of the pool, an error is thrown.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
Instance Properties
this.creationStack → (string|undefined)
(string|undefined)
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
this.delay → number
number
The minimum delay between objects being made available, in milliseconds. If this is 0, no minimum delay is enforced.
this.lastAccess → (number|null)
(number|null)
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.