Loading src/lib/threadpool/test_threadpool.c +27 −3 Original line number Diff line number Diff line Loading @@ -65,6 +65,13 @@ static void task_cb(void *udata) { dump_stats("", &stats); } static void inf_loop_cb(void *env) { (void)env; for (;;) { sleep(1); } } int main(int argc, char **argv) { uint8_t sz2 = 8; uint8_t max_threads = 8; Loading Loading @@ -112,11 +119,28 @@ int main(int argc, char **argv) { sleep(1); } printf("shutting down...\n"); while (!threadpool_shutdown(t, false)) { printf("shutting down...\n"); task.task = inf_loop_cb; size_t counterpressure = 0; while (!threadpool_schedule(t, &task, &counterpressure)) { usleep(10 * 1000); } sleep(1); const int THREAD_SHUTDOWN_SECONDS = 5; printf("shutting down...\n"); int limit = (1000 * THREAD_SHUTDOWN_SECONDS)/10; for (int i = 0; i < limit; i++) { if (threadpool_shutdown(t, false)) { break; } (void)poll(NULL, 0, 10); if (i == limit - 1) { printf("cancelling thread in intentional infinite loop\n"); threadpool_shutdown(t, true); } } threadpool_free(t); return 0; } Loading
src/lib/threadpool/test_threadpool.c +27 −3 Original line number Diff line number Diff line Loading @@ -65,6 +65,13 @@ static void task_cb(void *udata) { dump_stats("", &stats); } static void inf_loop_cb(void *env) { (void)env; for (;;) { sleep(1); } } int main(int argc, char **argv) { uint8_t sz2 = 8; uint8_t max_threads = 8; Loading Loading @@ -112,11 +119,28 @@ int main(int argc, char **argv) { sleep(1); } printf("shutting down...\n"); while (!threadpool_shutdown(t, false)) { printf("shutting down...\n"); task.task = inf_loop_cb; size_t counterpressure = 0; while (!threadpool_schedule(t, &task, &counterpressure)) { usleep(10 * 1000); } sleep(1); const int THREAD_SHUTDOWN_SECONDS = 5; printf("shutting down...\n"); int limit = (1000 * THREAD_SHUTDOWN_SECONDS)/10; for (int i = 0; i < limit; i++) { if (threadpool_shutdown(t, false)) { break; } (void)poll(NULL, 0, 10); if (i == limit - 1) { printf("cancelling thread in intentional infinite loop\n"); threadpool_shutdown(t, true); } } threadpool_free(t); return 0; }