FS-9820 #resolve [Add thread_pool to libks]

This commit is contained in:
Anthony Minessale
2016-12-06 16:46:08 -06:00
parent b86f7a6d30
commit b6df83dd10
8 changed files with 339 additions and 4 deletions

View File

@@ -9,6 +9,11 @@ testpools_SOURCES = testpools.c tap.c
testpools_CFLAGS = $(AM_CFLAGS)
testpools_LDADD = $(TEST_LDADD)
check_PROGRAMS += test_thread_pools
test_thread_pools_SOURCES = test_thread_pools.c tap.c
test_thread_pools_CFLAGS = $(AM_CFLAGS)
test_thread_pools_LDADD = $(TEST_LDADD)
check_PROGRAMS += testthreadmutex
testthreadmutex_SOURCES = testthreadmutex.c tap.c
testthreadmutex_CFLAGS = $(AM_CFLAGS)

View File

@@ -29,12 +29,19 @@ int qtest1(int loops)
ks_q_t *q;
ks_pool_t *pool;
int i;
int r = 1;
void *pop;
ks_pool_open(&pool);
ks_q_create(&q, pool, loops);
ks_thread_create(&thread, test1_thread, q, pool);
if (ks_q_pop_timeout(q, &pop, 500) != KS_STATUS_TIMEOUT) {
r = 0;
goto end;
}
for (i = 0; i < 10000; i++) {
int *val = (int *)ks_pool_alloc(pool, sizeof(int));
*val = i;
@@ -57,11 +64,13 @@ int qtest1(int loops)
ks_q_push(q, val);
}
end:
ks_q_destroy(&q);
ks_pool_close(&pool);
return 1;
return r;
}