1 Star 0 Fork 1

Darker/线程池

forked from lindx/线程池 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
threadpool.h 890 Bytes
一键复制 编辑 原始数据 按行查看 历史
#ifndef __threadpool_h__
#define __threadpool_h__
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include "condition.h"
#define GET_THREAD_ID (int)pthread_self()
typedef void *(*task_fuc)(void *arg);
typedef struct task
{
task_fuc func;
void *arg;
struct task *next;
}task_t;
typedef struct threadpool
{
condition_t ready;
task_t *first; //任务队列头指针
task_t *last; //任务队列尾指针
int counter; //当前线程数
int idle; //正在等待任务的线程数
int max_threads; //最大允许的线程数
int quit; //销毁线程池的时候置位1
}threadpool_t;
threadpool_t *threadpool_create(int threads); //线程池创建
void threadpool_destroy(threadpool_t *pool); //线程池销毁
void threadpool_add_task(threadpool_t *pool, task_fuc func, void *arg);
#endif
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/wu-jitao/threadpool.git
[email protected]:wu-jitao/threadpool.git
wu-jitao
threadpool
线程池
master

搜索帮助