-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpool.h
39 lines (31 loc) · 769 Bytes
/
pool.h
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
//
// Created by lklake on 2019/7/7.
//
#ifndef DHT_POOL_H
#define DHT_POOL_H
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include "queue.h"
typedef struct _pool{
pthread_mutex_t lock;
pthread_cond_t condition;
pthread_t* thread_list;
int power;
int thread_num;
queue* wait_queue;
void (*start)(struct _pool* this);
void (*add_task)(struct _pool* this,void* data,void(*)(void*));
void (*distroy)(struct _pool* this);
}pool;
typedef struct _task{
void (*func)(void* data);
void* data;
}task;
void pool_init(pool*,int num);
void* worker(void *arg);
void pool_start(pool* );
void pool_distroy(pool* pool_instance);
void add_task(pool*,void* data,void (*)(void*));
#endif //DHT_POOL_H