IPool

Core pool implementation.

Constructors

this
this()

Constructor

Members

Functions

clear
typeof(this) clear()

Recycles all items in the pool.

deleteItem
void deleteItem(Item item)

Deletes item and sets it to null.

fill_
typeof(this) fill_(size_t num, Item new_item)

Ensures that the pool contains at least the specified number of items. Useful to pre-allocate a pool of a certain size.

getItemIndex
size_t getItemIndex(Item item)

Gets the object pool index of item.

get_
Item get_(Item new_item)

Takes an idle item from the pool or creates a new one if all items are busy or the pool is empty.

isBusy
bool isBusy(Item item)

Checks if item is currently busy.

isNull
bool isNull(Item item)

Checks if item is null.

isSame
bool isSame(Item a, Item b)

Checks a and b for identity.

is_limited
bool is_limited()
length
size_t length()

Returns the number of items in pool.

limit
size_t limit()

Returns the limit of number of items in pool or unlimited if currently unlimited.

num_busy
size_t num_busy()

Returns the number of busy items in pool.

num_idle
size_t num_idle()

Returns the number of idle items in pool.

opIndex_
Item opIndex_(size_t n)

Obtains the n-th pool item. n must be less than the value returned by length().

recycle_
void recycle_(Item item_in)

Puts item back to the pool.

resetItem
void resetItem(Item item)

Resets item.

setItemIndex
void setItemIndex(Item item, size_t n)

Sets the object pool index to item.

setLimit
size_t setLimit(size_t limit)

Sets the limit of number of items in pool or disables limitation for limit = unlimited. When limiting the pool, any excess idle items are reset and deleted.

truncate
void truncate(size_t remove)

Removes idle items from the pool. Excess idle items are reset and deleted.

Unions

Item
union Item

Pool item union. The list of pool items is an array of Item; the subclass specifies which member is actually used.

Variables

items
Item[] items;

List of items (objects) in pool, busy items first

limited
bool limited;

May be set to true at any time to limit the number of items in pool to the current number or to false to disable limitation.

num_busy_
size_t num_busy_;

Number of busy items in pool

Inherited Members

From IPoolInfo

length
size_t length()

Returns the number of items in pool.

num_busy
size_t num_busy()

Returns the number of busy items in pool.

From ILimitable

unlimited
size_t unlimited;

Magic limit value indicating no limitation

setLimit
size_t setLimit(size_t limit)

Sets the limit of number of items in pool or disables limitation for limit = unlimited. When limiting the pool, any excess idle items are reset and deleted.

Meta