Beispiel #1
0
void *_merge_job(void *arg)
{
	int lsn;
	struct index *idx;
	struct skiplist *list;
	struct sst *sst;
	struct log *log;

	/* Lock begin */

	idx = (struct index*)arg;
	lsn = idx->park->lsn;
	list = idx->park->list;
	sst = idx->sst;
	log = idx->log;

	if(list == NULL) 
		goto merge_out;

	pthread_mutex_lock(&idx->merge_mutex);
	sst_merge(sst, list, 0);
	pthread_mutex_unlock(&idx->merge_mutex);

	/* Lock end */
	log_remove(log, lsn);

merge_out:
	pthread_detach(pthread_self());
	pthread_exit(NULL);
}
Beispiel #2
0
void _index_flush(struct index *idx)
{
	struct skiplist *list;
	/* Waiting bg merging thread done */
	pthread_mutex_lock(&idx->merge_mutex);
	pthread_mutex_unlock(&idx->merge_mutex);

	list = idx->list;
	if(list && list->count > 0) {
		sst_merge(idx->sst, list, 0);
		log_remove(idx->log, idx->lsn);
	}
}
Beispiel #3
0
void log_clear(log_t *log) {
	node_t *node;
	for (node = log->messages.head; node; node = node->next)
		log_remove(log, node);
}