fm.liveswitch.Pool< T > Class Template Reference

A pool of objects. More...

Public Member Functions

boolean destroy (fm.liveswitch.IAction1< T > destroyCallback)
 Removes all items from the pool and calls a callback for each one. More...
 
get ()
 Gets an object. More...
 
int getAvailable ()
 Gets the number of available objects. More...
 
int getMaxSize ()
 Gets the maximum size. More...
 
int getMinSize ()
 Gets the minimum size. More...
 
int getSize ()
 Gets the current size of the pool. More...
 
 Pool (fm.liveswitch.IFunction0< T > createObject)
 Initializes a new instance of the fm.liveswitch.Pool class with a minimum size of 0 and a maximum size of 2,147,483,647. More...
 
 Pool (fm.liveswitch.IFunction0< T > createObject, int minSize)
 Initializes a new instance of the fm.liveswitch.Pool class with a specified minimum size and a maximum size of 2,147,483,647. More...
 
 Pool (fm.liveswitch.IFunction0< T > createObject, int minSize, int maxSize)
 Initializes a new instance of the fm.liveswitch.Pool class. More...
 
boolean put (T item)
 Put an object back. More...
 

Detailed Description

A pool of objects.

Constructor & Destructor Documentation

◆ Pool() [1/3]

fm.liveswitch.Pool< T >.Pool ( fm.liveswitch.IFunction0< T >  createObject)

Initializes a new instance of the fm.liveswitch.Pool class with a minimum size of 0 and a maximum size of 2,147,483,647.

Parameters
createObjectA function that creates an object.

◆ Pool() [2/3]

fm.liveswitch.Pool< T >.Pool ( fm.liveswitch.IFunction0< T >  createObject,
int  minSize 
)

Initializes a new instance of the fm.liveswitch.Pool class with a specified minimum size and a maximum size of 2,147,483,647.

Parameters
createObjectA function that creates an object.
minSizeThe minimum size.

◆ Pool() [3/3]

fm.liveswitch.Pool< T >.Pool ( fm.liveswitch.IFunction0< T >  createObject,
int  minSize,
int  maxSize 
)

Initializes a new instance of the fm.liveswitch.Pool class.

with a specified minimum size and a specified maximum size.

Parameters
createObjectA function that creates an object.
minSizeThe minimum size.
maxSizeThe maximum size.

Member Function Documentation

◆ destroy()

boolean fm.liveswitch.Pool< T >.destroy ( fm.liveswitch.IAction1< T >  destroyCallback)

Removes all items from the pool and calls a callback for each one.

Parameters
destroyCallback

◆ get()

T fm.liveswitch.Pool< T >.get ( )

Gets an object.

◆ getAvailable()

int fm.liveswitch.Pool< T >.getAvailable ( )

Gets the number of available objects.

◆ getMaxSize()

int fm.liveswitch.Pool< T >.getMaxSize ( )

Gets the maximum size.

Value must be >= 0. A value of 0 indicates no maximum.

◆ getMinSize()

int fm.liveswitch.Pool< T >.getMinSize ( )

Gets the minimum size.

Value must be >= 0.

◆ getSize()

int fm.liveswitch.Pool< T >.getSize ( )

Gets the current size of the pool.

◆ put()

boolean fm.liveswitch.Pool< T >.put ( item)

Put an object back.

Parameters
item