Add support for loadable modules on POSIX systems

This commit is contained in:
Jason Turner
2009-09-06 23:33:03 +00:00
parent cba5731576
commit 7cc6a3cab9
10 changed files with 196 additions and 10 deletions

View File

@@ -218,14 +218,16 @@ namespace chaiscript
* Drop objects from the cache where there is only one (ie, our)
* reference to it, so it may be destructed
*/
void cull()
void cull(bool force = false)
{
++m_cullcount;
if (m_cullcount % 10 != 0)
if (force || m_cullcount % 10 != 0)
{
return;
}
std::map<const void *, Data >::iterator itr = m_ptrs.begin();
while (itr != m_ptrs.end())
@@ -279,11 +281,16 @@ namespace chaiscript
/**
* Return a reference to the static global Object_Cache
*/
Object_Cache &get_object_cache()
static Object_Cache &get_object_cache()
{
static chaiscript::threading::Thread_Storage<Object_Cache> oc;
return *oc;
}
}
static void clear_cache()
{
get_object_cache().m_ptrs.clear();
}
/**
* copy the values stored in rhs.m_data to m_data