int main() { threadpool_t *tpool; int rc = threadpool_init(&tpool); task_t t1 = { test1, (void *) 0}; task_t t2 = { test2, (void *) 0}; assert(rc == 0); threadpool_add_task(tpool, &t1); threadpool_add_task(tpool, &t2); threadpool_run(tpool); threadpool_exit(tpool); pthread_exit(NULL); }
int main(int argc, char *argv[]) { long i = 10000; threadpool_t *pool = threadpool_create(10, 100, 0); assert(pool); while (i > 0) { if (i % 3 == 0) { assert(threadpool_add_task(pool, task3, (void*)(long)(pool->threads_num), 1000) == 0); } else if (i % 3 == 1) { assert(threadpool_add_task(pool, task2, (void*)(long)(pool->threads_num), 500) == 0); } else { assert(threadpool_add_task(pool, task1, (void*)(long)(pool->threads_num), 0) == 0); } i--; } while (threadpool_task_over(pool, 1, 3) != 0) {}; threadpool_exit(pool); assert(threadpool_destroy(pool, 1, 3) == 0); exit(0); }