Egglib 2.1.11
C++ library reference manual
Public Member Functions | List of all members
EdgePool Class Reference

Pool of Edge objects. More...

#include <Edge.hpp>

Public Member Functions

 EdgePool ()
 Default constructor (nothing allocated)
 
virtual ~EdgePool ()
 Destructor.
 
void set (unsigned int numberOfSegments, unsigned numberOfPreAllocated)
 Configure pool. More...
 
void clear ()
 Frees internally stored memory. More...
 
Edgedeliver ()
 Deliver an Edge. More...
 
void releaseLast ()
 Release an Edge. More...
 
void releaseAll ()
 Release all Edge's. More...
 

Detailed Description

Pool of Edge objects.

Holds a pool of Edge objects that can be recycled to spare the building burden. A construction time, a number of Edge objects equals to the predicted number of needed instances should be requested. The Edge's will be prebuilt immediately and delivered upon request. After use, the Edge's should be released. It is only possible to release the last issued Edge instance or all of them at once.

Member Function Documentation

void clear ( )

Frees internally stored memory.

This invalidate all points that have been delivered previously. However, any previously set number of segments (0, by default) is retained.

Edge * deliver ( )

Deliver an Edge.

The object must not be freed by the client! This object is allocated on the heap if the cache is not large enough, only reset if it was previously released, or just delivered if it is one of the initially allocated instances.

void releaseAll ( )

Release all Edge's.

Release all delivered Edges. The instances are only cached for a potential future use; they are not freed nor reset immediately. If no Edge's are in use, nothing is done.

void releaseLast ( )

Release an Edge.

Release the last delivered Edge. The instance is only cached for a potential future use; it is not freed nor reset immediately. If no Edge's are in use, nothing is done.

void set ( unsigned int  numberOfSegments,
unsigned  numberOfPreAllocated 
)

Configure pool.

Pre-allocates a given number of Edge objects. The objects will be immediately available.

Data previously allocated (by a previous call of this function or by the deliver() method) will be lost so it can be required to use clear() before.

Parameters
numberOfSegmentsthe number of segments of the simulation; all Edge instances will use this value.
numberOfPreAllocatedthe number of Edge that should be kept ready for immediate use.

The documentation for this class was generated from the following files:

Hosted by 
Get EggLib at SourceForge.net. Fast, secure and Free Open Source software downloads