feisty meow concerns codebase
2.140
|
Holds onto memory chunks that are allocated globally within the program. More...
#include <static_memory_gremlin.h>
Public Member Functions | |
static_memory_gremlin () | |
~static_memory_gremlin () | |
DEFINE_CLASS_NAME ("static_memory_gremlin") | |
void | enable_debugging (bool verbose) |
if "verbose" is true, then the object will produce a noisy log. More... | |
bool | put (const char *unique_name, basis::root_object *ptr) |
adds a "ptr" to the set of static objects under the "unique_name". More... | |
basis::root_object * | get (const char *unique_name) |
locates the pointer held for the "unique_name", if any. More... | |
const char * | find (const basis::root_object *ptr) |
locates the name for "ptr" in our objects. More... | |
void | ensure_space_exists () |
Public Member Functions inherited from basis::nameable | |
virtual const char * | class_name () const =0 |
Returns the bare name of this class as a constant character pointer. More... | |
Static Public Member Functions | |
static bool | __program_is_dying () |
Reports whether the program is shutting down currently. More... | |
static static_memory_gremlin & | __hoople_globals () |
Holds onto objects that have been allocated in a program-wide scope. More... | |
static basis::mutex & | __memory_gremlin_synchronizer () |
private object for static_memory_gremlin's use only. More... | |
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 35 of file static_memory_gremlin.h.
structures::static_memory_gremlin::static_memory_gremlin | ( | ) |
Definition at line 58 of file static_memory_gremlin.cpp.
References ensure_space_exists().
Referenced by __hoople_globals().
structures::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 68 of file static_memory_gremlin.cpp.
References NULL_POINTER, and basis::WHACK().
|
static |
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.
Definition at line 204 of file static_memory_gremlin.cpp.
References application::_global_argv, FUNCDEF, NULL_POINTER, program_wide_memories, and static_memory_gremlin().
|
static |
private object for static_memory_gremlin's use only.
Definition at line 109 of file static_memory_gremlin.cpp.
|
static |
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.
Definition at line 107 of file static_memory_gremlin.cpp.
structures::static_memory_gremlin::DEFINE_CLASS_NAME | ( | "static_memory_gremlin" | ) |
|
inline |
if "verbose" is true, then the object will produce a noisy log.
Definition at line 66 of file static_memory_gremlin.h.
References verbose.
void structures::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 175 of file static_memory_gremlin.cpp.
References NULL_POINTER, and structures::SMG_CHUNKING_FACTOR.
Referenced by put(), and static_memory_gremlin().
const char * structures::static_memory_gremlin::find | ( | const basis::root_object * | ptr | ) |
locates the name for "ptr" in our objects.
if it does not exist, then NULL_POINTER is returned.
Definition at line 132 of file static_memory_gremlin.cpp.
References NULL_POINTER.
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 NULL_POINTER 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 124 of file static_memory_gremlin.cpp.
References basis::negative(), and NULL_POINTER.
bool structures::static_memory_gremlin::put | ( | const char * | unique_name, |
basis::root_object * | 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 142 of file static_memory_gremlin.cpp.
References ensure_space_exists(), basis::non_negative(), and basis::WHACK().