spthreadpool.hpp
来自「spserver 是一个实现了半同步/半异步(Half-Sync/Half-As」· HPP 代码 · 共 47 行
HPP
47 行
/* * Copyright 2007 Stephen Liu * For license terms, see the file COPYING along with this library. */#ifndef __spthreadpool_hpp__#define __spthreadpool_hpp__#include <pthread.h>typedef struct tagSP_Thread SP_Thread_t;class SP_ThreadPool {public: typedef void ( * DispatchFunc_t )( void * ); SP_ThreadPool( int maxThreads, const char * tag = 0 ); ~SP_ThreadPool(); /// @return 0 : OK, -1 : cannot create thread int dispatch( DispatchFunc_t dispatchFunc, void *arg ); int getMaxThreads();private: char * mTag; int mMaxThreads; int mIndex; int mTotal; int mIsShutdown; pthread_mutex_t mMainMutex; pthread_cond_t mIdleCond; pthread_cond_t mFullCond; pthread_cond_t mEmptyCond; SP_Thread_t ** mThreadList; static void * wrapperFunc( void * ); int saveThread( SP_Thread_t * thread );};#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?