pool_func.hpp File Reference

Some methods of Pool are placed here in order to reduce compilation time and binary size. More...

#include "alloc_func.hpp"
#include "mem_func.hpp"
#include "pool_type.hpp"

Go to the source code of this file.

Defines

#define DEFINE_POOL_METHOD(type)
 Helper for defining the method's signature.
#define INSTANTIATE_POOL_METHODS(name)
 Force instantiation of pool methods so we don't get linker errors.

Functions

 DEFINE_POOL_METHOD (inline)
 Create a clean pool.
 DEFINE_POOL_METHOD (inline void *)
 Makes given index valid.
 DEFINE_POOL_METHOD (void *)
 Allocates new item.
 DEFINE_POOL_METHOD (void)
 Deallocates memory used by this index and marks item as free.

Detailed Description

Some methods of Pool are placed here in order to reduce compilation time and binary size.

Definition in file pool_func.hpp.


Define Documentation

#define DEFINE_POOL_METHOD ( type   ) 
Value:
template <class Titem, typename Tindex, size_t Tgrowth_step, size_t Tmax_size, PoolType Tpool_type, bool Tcache, bool Tzero> \
  type Pool<Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero>

Helper for defining the method's signature.

Parameters:
type The return type of the method.

Definition at line 23 of file pool_func.hpp.

#define INSTANTIATE_POOL_METHODS ( name   ) 
Value:
template void * name ## Pool::GetNew(size_t size); \
  template void * name ## Pool::GetNew(size_t size, size_t index); \
  template void name ## Pool::FreeItem(size_t index); \
  template void name ## Pool::CleanPool();

Force instantiation of pool methods so we don't get linker errors.

Only methods accessed from methods defined in pool.hpp need to be forcefully instantiated.

Definition at line 217 of file pool_func.hpp.


Function Documentation

DEFINE_POOL_METHOD ( void   ) 

Deallocates memory used by this index and marks item as free.

Destroys all items in the pool and resets all member variables.

Parameters:
index item to deallocate
Precondition:
unit is allocated (non-NULL)
Note:
'delete NULL' doesn't cause call of this function, so it is safe

Definition at line 189 of file pool_func.hpp.

DEFINE_POOL_METHOD ( void *   ) 

Allocates new item.

Allocates new item with given index.

Parameters:
size size of item
Returns:
pointer to allocated item
Note:
error() on failure! (no free item)
Parameters:
size size of item
index index of item
Returns:
pointer to allocated item
Note:
usererror() on failure! (index out of range or already used)

Definition at line 150 of file pool_func.hpp.

References usererror().

DEFINE_POOL_METHOD ( inline void *   ) 

Makes given index valid.

Parameters:
size size of item
index index of item
Precondition:
index < this->size
this->Get(index) == NULL

Definition at line 98 of file pool_func.hpp.

References max(), and MemSetT().

DEFINE_POOL_METHOD ( inline  size_t  ) 

Create a clean pool.

Searches for first free index.

Resizes the pool so 'index' can be addressed.

Parameters:
name The name for the pool.
index index we will allocate later
Precondition:
index >= this->size
index < Tmax_size
Returns:
first free index, NO_FREE_ITEM on failure

Definition at line 66 of file pool_func.hpp.


Generated on Sun May 8 07:30:24 2011 for OpenTTD by  doxygen 1.6.1