summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
author@syxhe <https://t.me/syxhe>2025-04-24 23:08:28 -0500
committer@syxhe <https://t.me/syxhe>2025-04-24 23:08:28 -0500
commitee3621075106ac6cff84a94432c12c89c9e45979 (patch)
treeea8441f41633753d7d26434a91783333a801f41e /src/main.c
parentdb6aacd22f5c43cc6ea45e6c07bf962859ebac8d (diff)
Yeah this shit brokey
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c32
1 files changed, 25 insertions, 7 deletions
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 @@
7 7
8#include <errno.h> 8#include <errno.h>
9#include <error.h> 9#include <error.h>
10#include <threads.h>
11#include <unistd.h>
10 12
11#include <stdio.h>
12int testcb(void *data) { 13int testcb(void *data) {
13 if(!data) 14 if(!data)
14 return -1; 15 return -1;
@@ -17,14 +18,31 @@ int testcb(void *data) {
17 return 0; 18 return 0;
18} 19}
19 20
21int consumer(void *cq) {
22 if(!cq)
23 return -1;
24
25 cqueue *rcq = (cqueue*)cq;
26 for(task *tsk = NULL;;) {
27 tsk = cqueue_waitpop(rcq);
28 if(!tsk)
29 thrd_exit(-1);
30
31 task_fire(tsk);
32 }
33
34 return 0;
35}
36
20int main() { 37int main() {
21 // error(1, ENOTSUP, "No main file lol"); 38 // error(1, ENOTSUP, "No main file lol");
22 39
23 threadpool *tp = threadpool_init(2); 40 thrd_t thread;
24 task *tsk = task_init(testcb, "This is some data"); 41 cqueue *cq = cqueue_init(mtx_plain);
25 threadpool_addtask(tp, tsk); 42 thrd_create(&thread, consumer, cq);
26 threadpool_join(tp); 43 cqueue_addtask(cq, task_init(testcb, (void*)"This is some data"));
27 threadpool_free(tp); 44 sleep(10);
45 cqueue_free(cq);
28 46
29 return 0; 47 return 0;
30} \ No newline at end of file 48} \ No newline at end of file