34 Star 48 Fork 15

炕头哥 / Ppool

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
ppool.h 851 Bytes
一键复制 编辑 原始数据 按行查看 历史
炕头哥 提交于 2015-06-30 14:08 . 线程同步
#ifndef _PPOOL_H
#define _PPOOL_H
#include <pthread.h>
#include "ppool_queue.h"
typedef char pbool;
#define PTRUE 1
#define PFALSE 0
pthread_mutex_t PPOOL_LOCK;
#define ppool_entry() pthread_mutex_lock(&PPOOL_LOCK)
#define ppool_leave() pthread_mutex_unlock(&PPOOL_LOCK)
typedef struct
{
int pool_max_num; //线程池最大线程数量
int rel_num; //线程池中实例线程数
pool_w *head; //线程头
pthread_t *id; //线程id
pthread_mutex_t ppool_lock;
pthread_cond_t ppool_cond;
}pool_t;
//任务数据结构
typedef struct
{
int priority; //优先级
ppool_work task; //任务
void *arg; //参数
}pool_task;
//初始化一个线程池
pool_t *ppool_init(int pool_max_num);
//向线程池中添加一个任务
pbool ppool_add(pool_t *pool,pool_task *task);
//销毁一个线程池
void ppool_destroy(pool_t *pool);
#endif
C
1
https://gitee.com/brisk/Ppool.git
git@gitee.com:brisk/Ppool.git
brisk
Ppool
Ppool
master

搜索帮助