2005/5/9

     
 

class AbstractAllocator

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

acdk::lang::sys::AbstractAllocator Class Reference

#include <Allocator.h>

Inheritance diagram for acdk::lang::sys::AbstractAllocator:

acdk::lang::sys::Allocator acdk::lang::sys::SysObject 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

The AbstractAllocator allocates for Object types a little bit memory, where the beginning of the allocated block a pointer to the Allocator can be found.

The returned Object pointer is at offset ALIGNEDSIZEOF(MemChunkHeader).

All operations are protected by a simple/fast mutex


Public Member Functions

 AbstractAllocator (int allocatorFlags, const core_string &name)
virtual ~AbstractAllocator ()
virtual void lock ()
 in case of GC or other scanning activities the Allocator should be locked.

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

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

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

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

const char * name () const

Public Attributes

AllocatorInfo _allocInfo

Protected Attributes

core_fastmutex _lock


Constructor & Destructor Documentation

acdk::lang::sys::AbstractAllocator::AbstractAllocator int  allocatorFlags,
const core_string name
 

virtual acdk::lang::sys::AbstractAllocator::~AbstractAllocator  )  [virtual]
 


Member Function Documentation

virtual void* acdk::lang::sys::AbstractAllocator::allocate size_t  size,
AllocatedType  at = RawMem
[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

Implements acdk::lang::sys::Allocator.

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

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

Frees Memory.

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

Implements acdk::lang::sys::Allocator.

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

virtual bool acdk::lang::sys::AbstractAllocator::doGc bool  threadStorage = true,
bool  force = false
[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

Implements acdk::lang::sys::Allocator.

Reimplemented in acdk::lang::sys::PagedAllocator.

virtual const AllocatorInfo& acdk::lang::sys::AbstractAllocator::getAllocatorInfo  )  [inline, virtual]
 

Returns:
the filled AllocatorInfo

Implements acdk::lang::sys::Allocator.

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

Parameters:
flags combination of ListObjectsFlags

Implements acdk::lang::sys::Allocator.

Implemented in 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::AbstractAllocator::lock  )  [inline, virtual]
 

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

allocate() and deallocate should simply block

Implements acdk::lang::sys::Allocator.

const char* acdk::lang::sys::AbstractAllocator::name  )  const [inline]
 

virtual void* acdk::lang::sys::AbstractAllocator::raw_allocate size_t  size,
AllocatedType  type
[pure virtual]
 

Parameters:
size is including MemChunkHeader

Implemented in 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::AbstractAllocator::raw_deallocate size_t  size,
void *  ptr,
AllocatedType  type
[pure virtual]
 

Parameters:
size is including MemChunkHeader
ptr is including MemChunkHeader

Implemented in 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::AbstractAllocator::unlock  )  [inline, virtual]
 

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

allocate() and deallocate should simply block

Implements acdk::lang::sys::Allocator.


Member Data Documentation

AllocatorInfo acdk::lang::sys::AbstractAllocator::_allocInfo
 

core_fastmutex acdk::lang::sys::AbstractAllocator::_lock [protected]