Class: THeapChunkyMemory

Declaration: Memory.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

TChunkyMemory

Inherited By:

None.

Purpose:

THeapChunkyMemory is a concrete derived class of TChunkyMemory. It implements a chunky memory that takes its storage from the heap object passed to it at construction time.

Instantiation:

Allocate on the heap or the stack.

Deriving Classes:

Derived classes of this class override its virtual member functions to implement the defined protocol.

Concurrency:

Not multithread safe.

Resource Use:

No special requirements.

Member Function: THeapChunkyMemory::THeapChunkyMemory

  1. THeapChunkyMemory (size_t theChunkSize =kDefaultChunkSize)
  2. THeapChunkyMemory (TMemoryHeap * aHeap, size_t theChunkSize =kDefaultChunkSize)
  3. THeapChunkyMemory (const THeapChunkyMemory & aHeapChunkyMemory)

Interface Category:

API.

Purpose:

  1. Default constructor.
  2. Creates a THeapChunkyMemory that obtains its memory from a specific heap.
  3. Copy constructor.

Calling Context:

  1. Called to create an object that will be streamed into or to create a THeapChunkyMemory that obtains its memory from the default heap.
  2. Called to create a THeapChunkyMemory that does not use the default heap.
  3. Called to copy an object.

Parameters:

Return Value:

None.

Exceptions:

The copy constructor throws TGeneralKernelException(kInsufficientMemory) if there is not enough memory to copy the source object. Otherwise, throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

The copy constructor performs a deep copy of the source object.

Member Function: THeapChunkyMemory::operator=

THeapChunkyMemory & operator =(const THeapChunkyMemory & theHeapChunkyMemory)

Interface Category:

API.

Purpose:

Assignment operator.

Calling Context:

Called when an object is assigned to another compatible object.

Parameters:

Return Value:

A non-const reference to the left-hand side object.

Exceptions:

Throws TGeneralKernelException(kInsufficientMemory) if there is not enough memory to copy the source object.

Concurrency:

Not multithread safe.

Other Considerations:

This member function performs a deep copy of the source object.

Member Function: THeapChunkyMemory::~THeapChunkyMemory

virtual ~ THeapChunkyMemory ()

Interface Category:

API.

Purpose:

Destructor.

Calling Context:

Called to destroy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Calling the destructor releases all memory allocated for the chunky memory.

Member Function: THeapChunkyMemory::operator<<=

virtual TStream & operator <<= (TStream & fromWhere)

Interface Category:

API.

Purpose:

Stream-in operator.

Calling Context:

Called to stream in data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself in from.

Exceptions:

Throws TInvalidVersionError if the object read in from the stream has an invalid version number.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: THeapChunkyMemory::operator>>=

virtual TStream & operator >>=(TStream & toWhere) const

Interface Category:

API.

Purpose:

Stream-out operator.

Calling Context:

Called to stream out data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself out to.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: THeapChunkyMemory::SetChunkSize

virtual void SetChunkSize (size_t chunkSize)

Interface Category:

API.

Purpose:

Sets the size of chunk to allocate when more memory is requested.

Calling Context:

Called to change the size of chunk allocated by the THeapChunkyMemory.

Parameters:

Return Value:

None.

Exceptions:

Throws TGeneralKernelException(kBadArgument) if an invalid chunk size is passed.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: THeapChunkyMemory::GetChunkSize

virtual size_t GetChunkSize () const

Interface Category:

API.

Purpose:

Returns the size of chunk to allocate when more memory is requested.

Calling Context:

Called to determine information about how the THeapChunkyMemory object allocates new chunks.

Parameters:

Return Value:

A size_t that indicates the size of chunk that is allocated when AllocateMemoryChunk is called.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: THeapChunkyMemory::GetDefaultChunkSize

virtual size_t GetDefaultChunkSize () const

Interface Category:

API.

Purpose:

Returns the size of chunk to allocate when more memory is requested if a chunk size has not been specified.

Calling Context:

Called to determine information about how the THeapChunkyMemory object allocates new chunks.

Parameters:

Return Value:

A size_t that indicates the size of chunk that is allocated when AllocateMemoryChunk is called if a different chunk size has not been set by calling the SetChunkSize member function.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: THeapChunkyMemory::GetTotalSize

virtual size_t GetTotalSize () const

Interface Category:

API.

Purpose:

Returns the length of the chunky memory in bytes.

Calling Context:

Called to query the state of the THeapChunkyMemory object.

Parameters:

Return Value:

A size_t that is the length of the chunky memory in bytes.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: THeapChunkyMemory::LocateChunk

virtual void LocateChunk (size_t where, TMemorySurrogate & theContainingRange, size_t & offset)

Interface Category:

API.

Purpose:

Returns a TMemorySurrogate that describes the chunk that contains a specified offset.

Calling Context:

Called to query the state of the THeapChunkyMemory object or in preparation to access the memory that comprises the chunky memory.

Parameters:

Return Value:

None.

Exceptions:

Throw a TGeneralKernelException(kBadArgument) if where is beyond the end of the chunky memory.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: THeapChunkyMemory::CutBackTo

virtual void CutBackTo (size_t numberOfBytes)

Interface Category:

API.

Purpose:

Truncates the length of the chunky memory to the size passed.

Calling Context:

Called to modify the state of the THeapChunkyMemory.

Parameters:

Return Value:

None.

Exceptions:

Throws TGeneralKernelException(kBadArgument) if numberOfBytes is beyond the current end of the chunky memory.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: THeapChunkyMemory::AllocateMemoryChunk

virtual void AllocateMemoryChunk (TMemorySurrogate & theAllocatedRange)

Interface Category:

API.

Purpose:

Allocates a new chunk of memory and appends it to the chunky memory.

Calling Context:

Called when the chunky memory needs to be extended.

Parameters:

Return Value:

None.

Exceptions:

Throws TGeneralKernelException(kInsufficientMemory) if there is not enough memory to allocate another chunk.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: THeapChunkyMemory::GetChunkCollection

virtual void GetChunkCollection (TCollectionOf < TMemorySurrogate > & theCollection)

Interface Category:

API.

Purpose:

Appends, in order, TMemorySurrogates describing each chunk in the chunky memory to the collection passed in.

Calling Context:

Called to query the state of the THeapChunkyMemory object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.