new Pool(options)
The Pool constructor. When calling `fastPool()`, an instance of `Pool` will be returned.
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Properties
|
- Source:
Members
-
createObject :function
-
A function that returns a new object.
Type:
- function
- Source:
-
resetObject :function
-
A function that will turn a used, dirty object into a clean state.
Type:
- function
- Source:
Methods
-
ensureSize(size)
-
Makes sure that the pool has at least the given size.
Parameters:
Name Type Description size
number - Source:
-
preAllocate(size)
-
Pre-allocates the pool to the given size.
Parameters:
Name Type Description size
number The amount of objects to pre-allocate - Source:
-
takeBack(object)
-
Takes back an object and puts it back into the pool. If a `resetObject` function is given, it will be executed with the given object as first and only argument.
Parameters:
Name Type Description object
* The object to put back into the pool. - Source:
-
transfer()
-
Removes an object from the pool and hands it over to the caller. If the pool is empty, will create a new object.
- Source:
Returns:
An object- Type
- *