-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.c
More file actions
49 lines (38 loc) · 701 Bytes
/
test.c
File metadata and controls
49 lines (38 loc) · 701 Bytes
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 <stdio.h>
#include <unistd.h>
#include <sys/select.h>
#include "common.h"
#include "threadpool.h"
#include "queue.h"
#include "log.h"
void f1(void *arg) {
printf("call f1\n");
sleep(1);
}
void f2(void *arg) {
printf("call f2\n");
sleep(3);
}
int main()
{
void *pool = NULL;
void *q = NULL;
if (NULL == (pool = tp_init(MAX_POOL, INIT_POOL))) {
printf("tp_init error");
return ERROR;
}
if (NULL == (q = q_init(QUEUE_SIZE, pool))) {
printf("q_init error");
return ERROR;
}
int i = 0;
for (i = 0; i < 100; i++) {
q_add(q, f1, NULL);
q_add(q, f2, NULL);
}
while(OK != q_isempty(q)) {
sleep(0.1);
}
q_drop(q);
return OK;
}