Example #1
0
sqlx_cache_t *
sqlx_cache_init(void)
{
	guint i;
	sqlx_cache_t *cache;

	cache = g_malloc0(sizeof(*cache));
	cache->cool_grace_delay = SQLX_GRACE_DELAY_COOL;
	cache->hot_grace_delay = SQLX_GRACE_DELAY_HOT;
	cache->heat_threshold = 1;
	cache->used = FALSE;
	g_mutex_init(&cache->lock);
	cache->bases_by_name = g_tree_new_full(hashstr_quick_cmpdata,
			NULL, NULL, NULL);
	cache->bases_count = SQLX_MAX_BASES;
	cache->cond_count = SQLX_MAX_COND;
	cache->cond_array = g_malloc0(cache->cond_count * sizeof(GCond));
	cache->open_timeout = DEFAULT_CACHE_OPEN_TIMEOUT;
	BEACON_RESET(&(cache->beacon_free));
	BEACON_RESET(&(cache->beacon_idle));
	BEACON_RESET(&(cache->beacon_idle_hot));
	BEACON_RESET(&(cache->beacon_used));

	for (i=0; i<cache->cond_count ;i++)
		g_cond_init(cache->cond_array + i);

	sqlx_cache_reset_bases(cache, cache->bases_count);
	return cache;
}
Example #2
0
void
sqlx_cache_set_max_bases(sqlx_cache_t *cache, guint max)
{
	GRID_TRACE2("%s(%p,%u)", __FUNCTION__, cache, max);
	EXTRA_ASSERT(cache != NULL);
	EXTRA_ASSERT(max < 65536);
	sqlx_cache_reset_bases(cache, max);
}