git-svn-id: svn+ssh://garage/var/lib/gforge/svnroot/maemo-mapper/trunk@214
6c538b50-5814-0410-93ad-
8bdf4c0149d1
g_hash_table_remove(_map_cache.entries, &key);
}
g_hash_table_remove(_map_cache.entries, &key);
}
-void
-map_cache_init(size_t cache_size)
+static void
+map_cache_init_unlocked(size_t cache_size)
- g_mutex_lock(_mapdb_mutex);
if(_map_cache.entries == NULL)
_map_cache.entries = g_hash_table_new_full(map_cache_key_hash,
map_cache_key_equal, NULL, (GDestroyNotify)map_cache_entry_free);
if(_map_cache.entries == NULL)
_map_cache.entries = g_hash_table_new_full(map_cache_key_hash,
map_cache_key_equal, NULL, (GDestroyNotify)map_cache_entry_free);
if(_map_cache.p > cache_size)
_map_cache.p = cache_size;
map_cache_evict(0);
if(_map_cache.p > cache_size)
_map_cache.p = cache_size;
map_cache_evict(0);
+}
+
+void
+map_cache_init(size_t cache_size)
+{
+ g_mutex_lock(_mapdb_mutex);
+ map_cache_init_unlocked(cache_size);
g_mutex_unlock(_mapdb_mutex);
}
g_mutex_unlock(_mapdb_mutex);
}
-void
-map_cache_destroy(void)
+static void
+map_cache_destroy_unlocked(void)
- g_mutex_lock(_mapdb_mutex);
if(_map_cache.entries != NULL)
{
g_hash_table_destroy(_map_cache.entries);
if(_map_cache.entries != NULL)
{
g_hash_table_destroy(_map_cache.entries);
_map_cache.misses, 100*_map_cache.misses/(double)(
_map_cache.thits+_map_cache.bhits+_map_cache.misses));
}
_map_cache.misses, 100*_map_cache.misses/(double)(
_map_cache.thits+_map_cache.bhits+_map_cache.misses));
}
+}
+void
+map_cache_destroy(void)
+{
+ g_mutex_lock(_mapdb_mutex);
+ map_cache_destroy_unlocked();
g_mutex_unlock(_mapdb_mutex);
}
g_mutex_unlock(_mapdb_mutex);
}
map_cache_clean (void)
{
g_mutex_lock(_mapdb_mutex);
map_cache_clean (void)
{
g_mutex_lock(_mapdb_mutex);
- if(_map_cache.entries != NULL)
- g_hash_table_remove_all (_map_cache.entries);
+ gint old_size = _map_cache.cache_size;
+ map_cache_destroy_unlocked();
+ map_cache_init_unlocked(old_size);
g_mutex_unlock(_mapdb_mutex);
}
g_mutex_unlock(_mapdb_mutex);
}