Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

custmem.hpp File Reference


Detailed Description

InteLib custom memory management.

This file defines a template class which implements a kind of a custom memory management. It is used to be notably faster for classes for which lots of objects (of the same size) are made.

Definition in file custmem.hpp.

Go to the source code of this file.

Defines

#define INTELIB_CUSTOM_MEMORY_MANAGEMENT   1
 Set to 1 to use the custom memory management, 0 to disable it.
#define INTELIB_CMM_MAX_MEM_BLOCK   (256*1024)
#define INTELIB_DECLARE_CUSTOM_MEMORY_MANAGEMENT(classname)
 Macro to easily make any class to be allocated on a custom manner.
#define INTELIB_IMPLEMENT_CUSTOM_MEMORY_MANAGEMENT(classname)
 Implementation of a custom memory management.

Typedefs

typedef unsigned int size_t


Define Documentation

#define INTELIB_CUSTOM_MEMORY_MANAGEMENT   1
 

Set to 1 to use the custom memory management, 0 to disable it.

Definition at line 30 of file custmem.hpp.

#define INTELIB_CMM_MAX_MEM_BLOCK   (256*1024)
 

Definition at line 36 of file custmem.hpp.

#define INTELIB_DECLARE_CUSTOM_MEMORY_MANAGEMENT classname   ) 
 

Value:

private:                                                          \
  static class classname##MemoryManager TheMemoryManager;           \
  public:                                                           \
  void* operator new(size_t s);                                     \
  void operator delete(void *p, size_t s);
Macro to easily make any class to be allocated on a custom manner.

Just call this macro within the class definition

Note:
It leaves the protection mode 'public'. You might want to insert it right before the end of your class' definition.

Be sure to use INTELIB_IMPLEMENT_CUSTOM_MEMORY_MANAGEMENT somewhere in your implementation (.cpp) file so that all the necessary methods get implemented.

Definition at line 118 of file custmem.hpp.

#define INTELIB_IMPLEMENT_CUSTOM_MEMORY_MANAGEMENT classname   ) 
 

Value:

class classname##MemoryManager :                                  \
     public CustomMemoryManager<sizeof (classname),                 \
           INTELIB_CMM_MAX_MEM_BLOCK / sizeof(classname)> {}        \
       classname::TheMemoryManager;                                 \
  void* classname::operator new(size_t s)                           \
     { return TheMemoryManager.GetUnit(s); }                        \
  void classname::operator delete(void *p, size_t s)                \
     { return TheMemoryManager.ReleaseUnit(p, s); }
Implementation of a custom memory management.

This macro is to be inserted into the .cpp file along with the class definition for every class which is made to be allocated on the custom manner with the INTELIB_DECLARE_CUSTOM_MEMORY_MANAGEMENT macro

Definition at line 131 of file custmem.hpp.


Typedef Documentation

typedef unsigned int size_t
 

Definition at line 43 of file custmem.hpp.


Generated on Tue Dec 18 00:39:48 2007 for InteLib by  doxygen 1.4.1