summaryrefslogtreecommitdiff
path: root/src/main.c
blob: 95b55fffb5cd2d2ed3ee56d064988460764ed9b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "arena.h"
#include "ll.h"
#include "encryption.h"
#include "scanner.h"
#include "shared.h"
#include "threadpool.h"

#include <errno.h>
#include <error.h>
#include <threads.h>
#include <unistd.h>

int testcb(void *data) {
    if(!data)
        return -1;

    printf("%s\n", (char*)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");

    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;
}