Home Reference Source
public class | source

Pool

An object pool implementation. Used for pooling objects to avoid unnecessary garbage collection.

Constructor Summary

Public Constructor
public

Constructs a Pool instance.

Member Summary

Public Members
public

cID: integer

Incrementing id that keeps a count of the number of objects created

public

Map of pools in the format of PUID<String>: pool<Array>

public

The class type.

Method Summary

Public Methods
public

Determines if the object is able to be cloned or not.

public

Determines if a new object is able to be created.

public

Determines if the object is able to be instantiated or not.

public

create(functionOrObject: function | object): object | undefined

Attempts to create a new object either by creating a new instance or calling its clone method.

public

destroy(): *

Destroys all pools.

public

expire(obj: object): integer

Pushes an object into the pool.

public

get(obj: function | object, args: array): object

Gets an object either by creating a new one or retrieving it from the pool.

public

getCount(): integer

Gets a count of all objects in the pool.

Private Methods
private

_getList(uid: string): array

Gets the pool mapped to the UID.

Public Constructors

public constructor(): * source

Constructs a Pool instance.

Return:

*

void

Public Members

public cID: integer source

Incrementing id that keeps a count of the number of objects created

public list: object source

Map of pools in the format of PUID<String>: pool<Array>

public type: string source

The class type.

Public Methods

public canCloneObject(object: object): boolean source

Determines if the object is able to be cloned or not.

Params:

NameTypeAttributeDescription
object object

The object to check

Return:

boolean

public canCreateNewObject(object: object): boolean source

Determines if a new object is able to be created.

Params:

NameTypeAttributeDescription
object object

The object to check

Return:

boolean

public canInstantiateObject(object: object): boolean source

Determines if the object is able to be instantiated or not.

Params:

NameTypeAttributeDescription
object object

The object to check

Return:

boolean

public create(functionOrObject: function | object): object | undefined source

Attempts to create a new object either by creating a new instance or calling its clone method.

TODO COVERAGE - for the constructorArgs

Params:

NameTypeAttributeDescription
functionOrObject function | object

The object to instantiate or clone

Return:

object | undefined

public destroy(): * source

Destroys all pools.

Return:

*

void

public expire(obj: object): integer source

Pushes an object into the pool.

Params:

NameTypeAttributeDescription
obj object

The object to expire

Return:

integer

public get(obj: function | object, args: array): object source

Gets an object either by creating a new one or retrieving it from the pool.

Params:

NameTypeAttributeDescription
obj function | object

The function or object to get

args array

The args to pass to the function on creation

Return:

object

public getCount(): integer source

Gets a count of all objects in the pool.

Return:

integer

Private Methods

private _getList(uid: string): array source

Gets the pool mapped to the UID.

Params:

NameTypeAttributeDescription
uid string

The pool uid

Return:

array