Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

more::gen::recycler Class Template Reference

A type for recycling garbage collected objects. More...

#include <more/recycler.h>

Inheritance diagram for more::gen::recycler:

Inheritance graph
[legend]
Collaboration diagram for more::gen::recycler:

Collaboration graph
[legend]
List of all members.

Public Types

Public Methods

Static Public Attributes


Detailed Description

template<typename T>
class more::gen::recycler< T >

A type for recycling garbage collected objects.

Precondition:
For any object x of type T, x.unset_mark() must be valid, and x.is_marked() must be valid and return bool. x.is_marked() shall return false after construction of x and after x.unset_mark() is called. After the container has requested the client to mark all used objects, x.is_marked() shall return true iff the object is referred to by the client. Note that also the copy assignment of T shall preserve the mark bit, i.e. it shall not copy it.
Presently the recycler never frees chunks of memory, so its memory usage will stay at its peek. One method to free chunks, is to copy all objects unsing a new recycler, and destruct the old recycler.

Warning:
The interface of this type may change. It is intended for internal use, at least for the moment.
Todo:
Need a mechanism to merge chunks after a peek memory consumption. This will involve copying object, thus T must be copyable, and renaming pointers, which requires a function similar to the mark_all argument to the ctor. Also, see if this class can be isolated from this file, for more general application.


Member Typedef Documentation

template<typename T>
typedef T const* more::gen::recycler::const_pointer
 

template<typename T>
typedef T const& more::gen::recycler::const_reference
 

template<typename T>
typedef std::ptrdiff_t more::gen::recycler::difference_type
 

template<typename T>
typedef T* more::gen::recycler::pointer
 

template<typename T>
typedef T& more::gen::recycler::reference
 

template<typename T>
typedef std::size_t more::gen::recycler::size_type
 

Reimplemented from more::gen::recycler_base.

template<typename T>
typedef T more::gen::recycler::value_type
 


Constructor & Destructor Documentation

template<typename T>
more::gen::recycler< T >::recycler recycler_group   x [inline, explicit]
 

Construct a new recycler.

Parameters:
mark_all  is called during a GC to mark the objects, and it is assumed that it marks all used objects in this recycler and in all recyclers tied to it.
tied  if supplied means that there are references between this recycler and tied, so that that GC must be synchronized.


Member Function Documentation

template<typename T>
const_pointer more::gen::recycler< T >::address const_reference    r const [inline]
 

Returns &r.

template<typename T>
pointer more::gen::recycler< T >::address reference    r const [inline]
 

Returns &r.

template<typename T>
T* more::gen::recycler< T >::allocate size_type    n,
const_pointer    p = 0
[inline]
 

Return an object which is no longer in use.

Note that it may contain and old value, so is may be necessary to clear it. This can be done by assigning a new value using construct.

template<typename T>
void more::gen::recycler< T >::construct T *    p,
T const &    x
[inline]
 

Does p->~T(); new((void*)p) T(x); .

template<typename T>
void more::gen::recycler< T >::construct T *    p [inline]
 

Does p->~T(); new((void*)p) T; .

template<typename T>
void more::gen::recycler< T >::deallocate pointer    p,
size_type    n
[inline]
 

Does nothing.

template<typename T>
void more::gen::recycler< T >::destroy T *    [inline]
 

Does nothing.

template<typename T>
template<typename Function>
void more::gen::recycler< T >::for_each Function    f [inline]
 

template<typename T>
size_type more::gen::recycler< T >::max_size   [inline]
 

Returns 1.


Member Data Documentation

template<typename T>
const int more::gen::recycler::filling_denom = 3 [static]
 

template<typename T>
const int more::gen::recycler::filling_num = 2 [static]
 

The filling of chunks before GC is about filling_num/filling_denom.

This is a compile-time option which must be set in the source code.

template<typename T>
const size_type more::gen::recycler::value_count = 16 [static]
 


The documentation for this class was generated from the following file:
Generated on Sat Sep 7 19:12:35 2002 for more with Doxygen 1.2.13.1. Doxygen 1.2.13.1 is written and copyright 1997-2002 by Dimitri van Heesch.