Packagecom.desuade.utils
Classpublic class BasicObjectPool
InheritanceBasicObjectPool Inheritance Object

Language Version : ActionScript 3
Since : 04.06.2010
Runtime Versions : AIR 1.0, Flash Player 9.0.0

Creates a generic pool for any kind of object.



Public Properties
 PropertyDefined By
  clean : Function
The method used to clean objects on checkIn
BasicObjectPool
  expandSize : int
The size of each expansion for the object pool
BasicObjectPool
  length : int = 0
The current length of the pool
BasicObjectPool
  list : Array
[read-only] This is an array of all the actual objects currently available in the pool.
BasicObjectPool
  objectClass : Class
The class of objects used in and created by the pool
BasicObjectPool
  onLastCheckIn : Function
The method called when the last object is checkedIn
BasicObjectPool
  size : int = 0
The current size of the pool
BasicObjectPool
Public Methods
 MethodDefined By
  
BasicObjectPool(objectClass:Class, clean:Function = null, expandSize:int = 50, startSize:int = 0)
This creates a new BasicObjectPool.
BasicObjectPool
  
checkIn(item:*):void
Checks the item back into the pool.
BasicObjectPool
  
This checks an object out of the pool.
BasicObjectPool
  
dispose():void
Disposes of the pool and all it's objects
BasicObjectPool
  
make(amount:int = 1):void
Makes an object in the pool.
BasicObjectPool
  
remove(amount:int = 1):void
Removes an object in the pool.
BasicObjectPool
Property Detail
cleanproperty
public var clean:Function

The method used to clean objects on checkIn

expandSizeproperty 
public var expandSize:int

The size of each expansion for the object pool

lengthproperty 
public var length:int = 0

The current length of the pool

listproperty 
list:Array  [read-only]

This is an array of all the actual objects currently available in the pool. Use with caution.


Implementation
    public function get list():Array
objectClassproperty 
public var objectClass:Class

The class of objects used in and created by the pool

onLastCheckInproperty 
public var onLastCheckIn:Function

The method called when the last object is checkedIn

sizeproperty 
public var size:int = 0

The current size of the pool

Constructor Detail
BasicObjectPool()Constructor
public function BasicObjectPool(objectClass:Class, clean:Function = null, expandSize:int = 50, startSize:int = 0)

This creates a new BasicObjectPool.

Parameters
objectClass:Class — The class of objects used in and created by the pool
 
clean:Function (default = null) — The method used to clean objects on checkIn
 
expandSize:int (default = 50) — The size of each expansion for the object pool
 
startSize:int (default = 0) — The starting size of the pool
Method Detail
checkIn()method
public function checkIn(item:*):void

Checks the item back into the pool.

Parameters

item:* — The item to be checked back in

checkOut()method 
public function checkOut():*

This checks an object out of the pool. If there are no more available objects, the pool increases the amount by the expand size.

Returns
* — An instance of the objectClass
dispose()method 
public function dispose():void

Disposes of the pool and all it's objects

make()method 
public function make(amount:int = 1):void

Makes an object in the pool.

Parameters

amount:int (default = 1) — The amount of new objects to create

remove()method 
public function remove(amount:int = 1):void

Removes an object in the pool.

Parameters

amount:int (default = 1) — The amount of old objects to remove