Пример #1
0
int so_scheduler_shutdown(soscheduler *s)
{
    so *e = s->env;
    int rcret = 0;
    int rc = so_workersshutdown(&s->workers, &e->r);
    if (srunlikely(rc == -1))
        rcret = -1;
    if (s->i) {
        sr_free(&e->a, s->i);
        s->i = NULL;
    }
    sr_mutexfree(&s->lock);
    return rcret;
}
Пример #2
0
static void
mt_multi_stmt(stc *cx)
{
	cx->env = sp_env();
	t( cx->env != NULL );
	void *c = sp_ctl(cx->env);
	t( c != NULL );
	t( sp_set(c, "sophia.path", cx->suite->sophiadir) == 0 );
	t( sp_set(c, "scheduler.threads", "3") == 0 );
	t( sp_set(c, "log.path", cx->suite->logdir) == 0 );
	t( sp_set(c, "log.sync", "0") == 0 );
	t( sp_set(c, "log.rotate_sync", "0") == 0 );
	t( sp_set(c, "db", "test") == 0 );
	t( sp_set(c, "db.test.path", cx->suite->dir) == 0 );
	t( sp_set(c, "db.test.sync", "0") == 0 );
	cx->db = sp_get(c, "db.test");
	t( cx->db != NULL );
	t( sp_open(cx->env) == 0 );

	ssa a;
	ss_aopen(&a, &ss_stda);
	srscheme cmp;
	sr_schemeinit(&cmp);
	srkey *part = sr_schemeadd(&cmp, &a);
	t( sr_keysetname(part, &a, "key") == 0 );
	t( sr_keyset(part, &a, "u32") == 0 );
	ssinjection ij;
	memset(&ij, 0, sizeof(ij));
	srerror error;
	sr_errorinit(&error);
	srseq seq;
	sr_seqinit(&seq);
	sscrcf crc = ss_crc32c_function();
	sr r;
	sr_init(&r, &error, &a, &seq, SF_KV, SF_SRAW, &cmp, &ij, crc, NULL);

	soworkers w;
	so_workersinit(&w);
	void *ptr[2] = { cx->env, cx->db };
	t( so_workersnew(&w, &r, 5, multi_stmt_thread, (void*)ptr) == 0 );
	t( so_workersshutdown(&w, &r) == 0 );
	sr_schemefree(&cmp, &a);

	void *o = sp_get(c, "db.test.index.count");
	t( o != NULL );
	t( strcmp( sp_get(o, "value", NULL), "100000") == 0 );
	sp_destroy(o);

	t( sp_destroy(cx->env) == 0 );
}