-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
74 lines (54 loc) · 1.57 KB
/
main.c
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*****************************************************************************/
// 文件名 :main.c
// 概要 : 入口函数
// 作者 : sunyifeng
// 版本控制 ; 初版 2018-05-10
/*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <netdb.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <errno.h>
#include <pthread.h>
#include <signal.h> /* for signal */
#include <execinfo.h> /* for backtrace() */
#include "thread_pool.h"
void work(void* arg)
{
char *p= (char*) arg;
printf("threadpoolp callback fuction : %s.\n", p);
sleep(1);
return ;
}
int main()
{
int ret = 0;
ret = thread_pool_init(300, 500); //线程池初始化
if (VOS_OK != ret)
{
printf("thread_pool_init Fail!\n");
}
tp_thread_pool *pPoolTemp;
get_thread_pool(&pPoolTemp);
ret = tp_process_job(pPoolTemp, work, "1",NULL);
ret = tp_process_job(pPoolTemp, work, "2",NULL);
ret = tp_process_job(pPoolTemp, work, "3",NULL);
ret = tp_process_job(pPoolTemp, work, "4",NULL);
ret = tp_process_job(pPoolTemp, work, "5",NULL);
ret = tp_process_job(pPoolTemp, work, "6",NULL);
ret = tp_process_job(pPoolTemp, work, "7",NULL);
ret = tp_process_job(pPoolTemp, work, "8",NULL);
ret = tp_process_job(pPoolTemp, work, "9",NULL);
ret = tp_process_job(pPoolTemp, work, "10",NULL);
sleep(5);
tp_close(pPoolTemp);//销毁线程池
return VOS_OK;
}