Packagecom.elad.framework.objectPoolManager
Classpublic class ReusablePool

ReusablePool is a singleton objecet that holds an instances of classes and it's role is to manage Reusable objects that will be used by the Client.

The object pooling can boost performance; especially in cases where the resources used to initializing a class instance are high, the number of times the class will be usage is often, and the number of instantiations in use at any single time is low.


Example
     
  var reusable:Reusable = new Reusable();
  reusable.name = "FlexImage";
  reusable.object = new UIComponent();
  reusablePool.setReusable(reusable);
  
     



Protected Properties
 PropertyDefined by
  reusable : Reusable
[static] Temporary place holder for a reusable object.
ReusablePool
Public Methods
 MethodDefined by
  
ReusablePool(enforcer:AccessRestriction)
Internal constructor.
ReusablePool
  
acquireReusable(name:String):Reusable
Class acquireReusable is called when it client need a Reusable object The reusable object is cleared until the client return the object back to the pool via the releaseReusable method.
ReusablePool
  
[static] Method function to retrieve instance of object ReusablePool
ReusablePool
  
releaseReusable(releasedReusable:Reusable):void
Method will be used to release Reusable collection once the client finished using it.
ReusablePool
  
setMaxPoolSize(size:Number):void
Method to set the size of the collection.
ReusablePool
  
setReusable(reusable:Reusable):void
Method to add an object to the collection the collection, as long as the collection size is smaller than the max allowed pool.
ReusablePool
Property detail
reusableproperty
protected static var reusable:Reusable

Temporary place holder for a reusable object.

Constructor detail
ReusablePool()constructor
public function ReusablePool(enforcer:AccessRestriction)

Internal constructor. Should not be called from outside this class.

Parameters
enforcer:AccessRestriction — Object accessible to just this class to enforce singleton pattern.
Method detail
acquireReusable()method
public function acquireReusable(name:String):Reusable

Class acquireReusable is called when it client need a Reusable object The reusable object is cleared until the client return the object back to the pool via the releaseReusable method.

Parameters
name:String — The name of the reusable object.

Returns
Reusable — Reusable class which holds the name and the object.
getInstance()method 
public static function getInstance():ReusablePool

Method function to retrieve instance of object ReusablePool

Returns
ReusablePool — ReusablePool Instance
releaseReusable()method 
public function releaseReusable(releasedReusable:Reusable):void

Method will be used to release Reusable collection once the client finished using it.

Parameters
releasedReusable:Reusable — type Reusable class and holds the name and object to be returned to the collection.
setMaxPoolSize()method 
public function setMaxPoolSize(size:Number):void

Method to set the size of the collection. If the collection reaches the max allowed object the class will return an error message.

Parameters
size:Number — The size of the collection.
setReusable()method 
public function setReusable(reusable:Reusable):void

Method to add an object to the collection the collection, as long as the collection size is smaller than the max allowed pool.

Parameters
reusable:Reusable — type Reusable which holds the name and the object.