📄 spexecutor.hpp
字号:
/* * Copyright 2007 Stephen Liu * For license terms, see the file COPYING along with this library. */#ifndef __spexecutor_hpp__#define __spexecutor_hpp__#include <pthread.h>class SP_ThreadPool;class SP_Task {public: virtual ~SP_Task(); virtual void run() = 0;};class SP_SimpleTask : public SP_Task {public: typedef void ( * ThreadFunc_t ) ( void * ); SP_SimpleTask( ThreadFunc_t func, void * arg, int deleteAfterRun ); virtual ~SP_SimpleTask(); virtual void run();private: ThreadFunc_t mFunc; void * mArg; int mDeleteAfterRun;};class SP_Executor {public: SP_Executor( int maxThreads, const char * tag = 0 ); ~SP_Executor(); void execute( SP_Task * task ); void execute( void ( * func ) ( void * ), void * arg ); int getQueueLength(); void shutdown();private: static void msgQueueCallback( void * queueData, void * arg ); static void worker( void * arg ); static void * eventLoop( void * arg ); SP_ThreadPool * mThreadPool; void * mQueue; void * mEventBase; int mIsShutdown; pthread_mutex_t mMutex; pthread_cond_t mCond;};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -