以前用过的的一个线程池代码
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的那个也贴上来。就怕忘了。
#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的那个也贴上来。就怕忘了。
相关文章推荐
- 以前写的一个文件夹遍历代码
- 以前写的一个多路归并代码进行汇总并实现了增量更新
- 一个线程池实例代码的分析
- Linux C++ 一个线程池的简单实现(附代码)
- 100行Java代码构建一个线程池
- Java代码构建一个线程池
- Java代码构建一个线程池
- 用java代码构建一个线程池
- Linux C++ 一个线程池的简单实现(附代码)
- 求解,多线程时,线程池中一个线程内部代码抛出异常,那么这个线程能正常结束么?
- 100行Java代码构建一个线程池
- 分享一个c线程池实现代码
- Java代码构建一个线程池
- 从以前写过的一个代码想到的
- 100行Java代码构建一个线程池(zz)
- 100行Java代码构建一个线程池
- 100行Java代码构建一个线程池
- 用Java代码构建一个线程池
- Java代码构建一个线程池
- Java代码构建一个线程池