From ee3621075106ac6cff84a94432c12c89c9e45979 Mon Sep 17 00:00:00 2001 From: "@syxhe" Date: Thu, 24 Apr 2025 23:08:28 -0500 Subject: Yeah this shit brokey --- src/main.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 6af87ab..95b55ff 100644 --- a/src/main.c +++ b/src/main.c @@ -7,8 +7,9 @@ #include #include +#include +#include -#include int testcb(void *data) { if(!data) return -1; @@ -17,14 +18,31 @@ int testcb(void *data) { return 0; } +int consumer(void *cq) { + if(!cq) + return -1; + + cqueue *rcq = (cqueue*)cq; + for(task *tsk = NULL;;) { + tsk = cqueue_waitpop(rcq); + if(!tsk) + thrd_exit(-1); + + task_fire(tsk); + } + + return 0; +} + int main() { // error(1, ENOTSUP, "No main file lol"); - - threadpool *tp = threadpool_init(2); - task *tsk = task_init(testcb, "This is some data"); - threadpool_addtask(tp, tsk); - threadpool_join(tp); - threadpool_free(tp); + + thrd_t thread; + cqueue *cq = cqueue_init(mtx_plain); + thrd_create(&thread, consumer, cq); + cqueue_addtask(cq, task_init(testcb, (void*)"This is some data")); + sleep(10); + cqueue_free(cq); return 0; } \ No newline at end of file -- cgit v1.2.3