static_memory_gremlin Class Reference

Holds onto memory chunks that are allocated globally within the program. More...

#include <static_memory_gremlin.h>

Collaboration diagram for static_memory_gremlin:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 static_memory_gremlin ()
 ~static_memory_gremlin ()
void enable_debugging (bool verbose)
 if "verbose" is true, then the object will produce a noisy log.
bool put (const char *unique_name, object_base *ptr)
 adds a "ptr" to the set of static objects under the "unique_name".
object_baseget (const char *unique_name)
 locates the pointer held for the "unique_name", if any.
const char * find (const object_base *ptr)
 locates the name for "ptr" in our objects.
void ensure_space_exists ()

Detailed Description

Holds onto memory chunks that are allocated globally within the program.

The objects managed by the gremlin do not get destroyed until after the program begins shutting down. This file also provides the SAFE_STATIC macros that can be used for allocating static objects safely in a multi-threaded program.

Definition at line 37 of file static_memory_gremlin.h.


Constructor & Destructor Documentation

static_memory_gremlin::static_memory_gremlin (  ) 

Definition at line 83 of file static_memory_gremlin.cpp.

References ensure_space_exists().

static_memory_gremlin::~static_memory_gremlin (  ) 

when destroyed, it is assumed that the program's lifetime is over and all objects stored here are now unnecessary. this implements a regenerative scheme for when static shutdowns occur out of order; if an object has already been destroyed, it is recreated for the purposes of other statics being shutdown. eventually this should stabilize since it's completely unacceptable for static objects to depend on each other in a cycle.

Definition at line 93 of file static_memory_gremlin.cpp.

References NIL, non_continuable_error, program_is_dying(), and WHACK().


Member Function Documentation

void static_memory_gremlin::enable_debugging ( bool  verbose  )  [inline]

if "verbose" is true, then the object will produce a noisy log.

Definition at line 51 of file static_memory_gremlin.h.

bool static_memory_gremlin::put ( const char *  unique_name,
object_base ptr 
)

adds a "ptr" to the set of static objects under the "unique_name".

the name must really be unique or objects will collide. we recommend using an identifier based on a line number and filename where the static is going to be placed (see the safe static implementation below).

Definition at line 165 of file static_memory_gremlin.cpp.

References ensure_space_exists(), object_base::instance_name(), non_negative(), and WHACK().

Referenced by __memory_gremlin_synchronizer().

object_base * static_memory_gremlin::get ( const char *  unique_name  ) 

locates the pointer held for the "unique_name", if any.

if no pointer exists, then NIL is returned. NOTE: the returned pointer must not be destroyed, since the object could be used at any time during the program's lifetime.

Definition at line 147 of file static_memory_gremlin.cpp.

References negative(), and NIL.

Referenced by __memory_gremlin_synchronizer().

const char * static_memory_gremlin::find ( const object_base ptr  ) 

locates the name for "ptr" in our objects.

if it does not exist, then NIL is returned.

Definition at line 155 of file static_memory_gremlin.cpp.

References NIL.

void static_memory_gremlin::ensure_space_exists (  ) 

makes sure that the list of objects is large enough to contain all of the identifiers that have been issued.

Definition at line 198 of file static_memory_gremlin.cpp.

References NIL, non_continuable_error, and SMG_CHUNKING_FACTOR.

Referenced by put(), and static_memory_gremlin().


The documentation for this class was generated from the following files:
Generated on Fri Nov 28 04:31:01 2008 for HOOPLE Libraries by  doxygen 1.5.1