Holds onto memory chunks that are allocated globally within the program. More...
Public Member Functions
|void||enable_debugging (bool verbose)|
|if "verbose" is true, then the object will produce a noisy log. |
|bool||put (const char *unique_name, basis::root_object *ptr)|
|adds a "ptr" to the set of static objects under the "unique_name". |
|basis::root_object *||get (const char *unique_name)|
|locates the pointer held for the "unique_name", if any. |
|const char *||find (const basis::root_object *ptr)|
|locates the name for "ptr" in our objects. |
Static Public Member Functions
|static bool||__program_is_dying ()|
|Reports whether the program is shutting down currently. |
|static static_memory_gremlin &||__hoople_globals ()|
|Holds onto objects that have been allocated in a program-wide scope. |
|static basis::mutex &||__memory_gremlin_synchronizer ()|
|private object for static_memory_gremlin's use only. |
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.
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.
|static_memory_gremlin & structures::static_memory_gremlin::__hoople_globals||(||)||
Holds onto objects that have been allocated in a program-wide scope.
These objects will have a lifetime up to the point of normal static object destruction and then they will be cleaned up.
|mutex & structures::static_memory_gremlin::__memory_gremlin_synchronizer||(||)||
Reports whether the program is shutting down currently.
If this flag is true, then code should generally just return without doing anything where possible. It's especially important for long running loops or active threads to stop if they see this, although the normal program exit processes usually make it unnecessary.
|const char * structures::static_memory_gremlin::find||(||const basis::root_object *||ptr||)|
|root_object * structures::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.
|bool structures::static_memory_gremlin::put||(||const char *||unique_name,|
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).