Pool

Defines a pool for class objects. Objects can be fetched from the pool with make() and returned to the pool with dispose(). Using a reference that has been dispose()d has undefined behavior. make() may return memory that has been previously dispose()d.

Currently the pool has effect only if the GC is NOT used (i.e. either version(GC) or mem.isGCEnabled is false). Otherwise make just forwards to new and dispose does nothing.

Internally the implementation uses a singly-linked freelist with a global root. The "next" pointer is stored in the first word of each disposed object.

Members

Static functions

dispose
void dispose(T goner)

Signals to the pool that this object is no longer used, so it can recycle its memory.

make
T make(A args)

Returns a reference to a new object in the same state as if created with new T(args).

Meta