您的位置:首页 > 编程语言

以前用过的的一个线程池代码

2007-01-07 20:41 190 查看
#ifndef __THRMGR_H__
#define __THRMGR_H__

#include <pthread.h>
#include <sys/time.h>
#include <stdio.h>
#include <time.h>
#include <errno.h>
#include "memory.h"
#include <stdlib.h>

#define FALSE (0)
#define TRUE (1)

typedef struct work_item_tag

typedef struct work_queue_tag

typedef enum

typedef struct threadpool_tag

threadpool_t *thrmgr_new(int max_threads, int idle_timeout, void (*handler)(void *));
void thrmgr_destroy(threadpool_t *threadpool);
int thrmgr_dispatch(threadpool_t *threadpool, void *user_data);

#endif

work_queue_t *work_queue_new()

void work_queue_add(work_queue_t *work_q, void *data)

void *work_queue_pop(work_queue_t *work_q)

void thrmgr_destroy(threadpool_t *threadpool)

threadpool_t *thrmgr_new(int max_threads, int idle_timeout, void (*handler)(void *))

void *thrmgr_worker(void *arg)

int thrmgr_dispatch(threadpool_t *threadpool, void *user_data)

标准的一个在Linux下用的线程池代码,估计很多人都用得这个,改天把java的那个也贴上来。就怕忘了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: