2005/5/9

     
 

class Allocator

artefaktur
Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   Namespace Members   Compound Members   Related Pages  

acdk::lang::sys::Allocator Class Reference

#include <Allocator.h>

Inheritance diagram for acdk::lang::sys::Allocator:

acdk::lang::sys::SysObject acdk::lang::sys::AbstractAllocator acdk::lang::sys::BitmapPagedAllocator acdk::lang::sys::BoehmGCAllocator acdk::lang::sys::PagedAllocator acdk::lang::sys::RawAllocator acdk::lang::sys::TracedRawAllocator List of all members.

Detailed Description

API: ACDK
Heaps that manages memory An Allocator has a little overhead:.

AllocatorHeader: 0 - 4 (Allocator*) 5 - 8 size_t size of allocated chunk including AllocatorHeader acdk::lang::Object/Raw 9 - n the allocated memory
Author:
Roger Rene Kommer
Version:
Revision
1.21
Date:
Date
2005/02/05 10:44:59


Public Member Functions

 Allocator (int allocatorFlags=StandardAllocatorType)
virtual ~Allocator ()
 type of the allocated object

int getFlags ()
 combination of AllocatorTypeFlags

virtual void lock ()=0
 in case of GC or other scanning activities the Allocator should be locked.

virtual void unlock ()=0
 in case of GC or other scanning activities the Allocator should be locked.

virtual void * allocate (size_t size, AllocatedType at=RawMem)=0
 Allocates Memory.

virtual void deallocate (void *ptr, AllocatedType at=RawMem)=0
 Frees Memory.

virtual void listObjects (::acdk::lang::ref::NotifyObjectEventListener *listener, int flags)=0
virtual const AllocatorInfogetAllocatorInfo ()=0
virtual bool doGc (bool threadStorage=true, bool force=false)=0
 try to garbage collect items

void initObjectPtr (void *ptr, AllocatedType type)
 use to initialize Object flags probably has no effects

void * os_alloc (size_t size)
 underlying allocation mechanism via operator ::new may call doGc and or throw OutOfMemoryError

void os_dealloc (size_t size, void *ptr)
 dealocate memory via operator ::delete


Static Public Member Functions

MemChunkHeadergetHeaderFromObject (void *obj)
MemChunkHeadergetHeaderFromChunk (void *obj)
size_t getHeaderSize ()
void * getObjectFromChunk (void *ptr)
void * getChunkFromObject (void *ptr)

Public Attributes

int flags
 bit combination of AllocatorTypeFlags


Constructor & Destructor Documentation

acdk::lang::sys::Allocator::Allocator int  allocatorFlags = StandardAllocatorType  )  [inline]
 

virtual acdk::lang::sys::Allocator::~Allocator  )  [inline, virtual]
 

type of the allocated object

See also:
acdk::lang::TracedRawAllocatorInfo


Member Function Documentation

virtual void* acdk::lang::sys::Allocator::allocate size_t  size,
AllocatedType  at = RawMem
[pure virtual]
 

Allocates Memory.

It is important, that the Allocator itself will be found in MemChunkHeader directly before this memory location)

Parameters:
size size of Object (not including MemChunkHeader)
Returns:
the raw preinitialized Object not including MemChunkHeader

Implemented in acdk::lang::sys::AbstractAllocator, acdk::lang::sys::BitmapPagedAllocator, acdk::lang::sys::BoehmGCAllocator, acdk::lang::sys::PagedAllocator, and acdk::lang::sys::TracedRawAllocator.

virtual void acdk::lang::sys::Allocator::deallocate void *  ptr,
AllocatedType  at = RawMem
[pure virtual]
 

Frees Memory.

Parameters:
ptr points to user object (not including MemChunkHeader)

Implemented in acdk::lang::sys::AbstractAllocator, acdk::lang::sys::BitmapPagedAllocator, acdk::lang::sys::BoehmGCAllocator, acdk::lang::sys::PagedAllocator, and acdk::lang::sys::TracedRawAllocator.

virtual bool acdk::lang::sys::Allocator::doGc bool  threadStorage = true,
bool  force = false
[pure virtual]
 

try to garbage collect items

Parameters:
threadStorage if true only object allocated in the current thread should be gced
force if true also release internal buffer
Returns:
true if any storage was freed

Implemented in acdk::lang::sys::AbstractAllocator, and acdk::lang::sys::PagedAllocator.

virtual const AllocatorInfo& acdk::lang::sys::Allocator::getAllocatorInfo  )  [pure virtual]
 

Returns:
the filled AllocatorInfo

Implemented in acdk::lang::sys::AbstractAllocator.

void* acdk::lang::sys::Allocator::getChunkFromObject void *  ptr  )  [inline, static]
 

int acdk::lang::sys::Allocator::getFlags  )  [inline]
 

combination of AllocatorTypeFlags

See also:
AllocatorTypeFlags

MemChunkHeader* acdk::lang::sys::Allocator::getHeaderFromChunk void *  obj  )  [inline, static]
 

MemChunkHeader* acdk::lang::sys::Allocator::getHeaderFromObject void *  obj  )  [inline, static]
 

size_t acdk::lang::sys::Allocator::getHeaderSize  )  [inline, static]
 

void* acdk::lang::sys::Allocator::getObjectFromChunk void *  ptr  )  [inline, static]
 

void acdk::lang::sys::Allocator::initObjectPtr void *  ptr,
AllocatedType  type
 

use to initialize Object flags probably has no effects

Todo:
check if this function is superflous

virtual void acdk::lang::sys::Allocator::listObjects ::acdk::lang::ref::NotifyObjectEventListener listener,
int  flags
[pure virtual]
 

Parameters:
flags combination of ListObjectsFlags

Implemented in acdk::lang::sys::AbstractAllocator, acdk::lang::sys::RawAllocator, acdk::lang::sys::BitmapPagedAllocator, acdk::lang::sys::BoehmGCAllocator, acdk::lang::sys::PagedAllocator, and acdk::lang::sys::TracedRawAllocator.

virtual void acdk::lang::sys::Allocator::lock  )  [pure virtual]
 

in case of GC or other scanning activities the Allocator should be locked.

allocate() and deallocate should simply block

Implemented in acdk::lang::sys::AbstractAllocator.

void* acdk::lang::sys::Allocator::os_alloc size_t  size  ) 
 

underlying allocation mechanism via operator ::new may call doGc and or throw OutOfMemoryError

void acdk::lang::sys::Allocator::os_dealloc size_t  size,
void *  ptr
 

dealocate memory via operator ::delete

virtual void acdk::lang::sys::Allocator::unlock  )  [pure virtual]
 

in case of GC or other scanning activities the Allocator should be locked.

allocate() and deallocate should simply block

Implemented in acdk::lang::sys::AbstractAllocator.


Member Data Documentation

int acdk::lang::sys::Allocator::flags
 

bit combination of AllocatorTypeFlags