📄 warthreadpooltask.h
字号:
/** */#ifndef WAR_THREAD_POOL_TASK_H#define WAR_THREAD_POOL_TASK_H/* SYSTEM INCLUDES *//* PROJECT INCLUDES */#ifndef WAR_THREAD_H# include "WarThread.h"#endif#ifndef WAR_TIME_H# include "WarTime.h"#endif/* LOCAL INCLUDES *//* FORWARD REFERENCES */class WarThreadForPool;class WarThreadPool;#ifdef __cplusplusextern "C" {#endif/****************** BEGIN OLD STYLE C spesific ********//****************** END OLD STYLE C spesific **********/#ifdef __cplusplus }#endif/****************** BEGIN C++ spesific ****************/#ifdef __cplusplusclass WarThreadPoolTask : public WarSmartPointer{public: /// enum StandardRequestTypesE { /// Overrides declare their own request types REQUEST_NOOP }; /// enum RequestStateE { /// Not sent to queue yet STATE_NOT_SET, /// Peding for an available thread STATE_QUEUED, /// Currently being processed STATE_PROCESSING, /// Processed STATE_PROCESSED, /// STATE_ABORTED }; /** The priority of a request Requests are inserted into the request/queue, sorted on priority. Besides the priority-level, the priority also determines if a new thread can be created if no threads are free to handle the request imediately. @see WarThreadPool::PushTask() */ enum TaskPriorityE { /// A new thread is created if no free threads exist PRI_HIGHEST, /// Sent at once, a new thread is created if m_CurrentThreads < mMaxThreads PRI_HIGH, /// Same as above. {\bfUse this for all "normal" requets} PRI_NORMAL, /// A new thread is not created PRI_LOW, /// Same as above PRI_VERY_LOW }; // LIFECYCLE /// WarThreadPoolTask(int Type = REQUEST_NOOP); // OPERATIONS // ACCESS // INQUIRY /// RequestStateE GetState() const { return mState; } /// war_ccstr_t GetStateName() const; /// const int GetType() const { return mType; } /// Must be overloaded virtual std::string GetTypeName() const; /// Must be overloaded, virtual const std::string GetInfo() const; /// const int GetPriority() const { return mPriority; } /// war_ccstr_t GetPriorityName() const; /// war_uint32_t GetElapsedTimeMs() const; /// int GetTaskId() { return mTaskCookie; } protected: friend class WarThreadForPool; friend class WarThreadPool; // Override to implement the objects purpose virtual void OnProcessing(WarThreadForPool * pThread) { ; // Nothing } virtual ~WarThreadPoolTask(); /// Ovveride and return false to leave in WarThreadPool::mDoneQueue virtual bool OnProcessed() const { return true; } // Ovveride and return false to leave in WarThreadPool::mDoneQueue virtual bool OnAborted() const { return true; } /// virtual void SetState(RequestStateE State); /// Current state RequestStateE mState; /// Request type int mType; /// Pointer to the assigned thread. WarThreadForPool *mpThread; /// Error carrier between threads WarError m_Result; /// Used to sort tasks in the queue. Higher priority goes first TaskPriorityE mPriority; /// WarTime mStartTime; /// WarTime mEndTime;private: static int msTotalTaskCnt; int mTaskCookie;};/* INLINE METHODS *//* EXTERNAL REFERENCES */#endif /* __cplusplus *//****************** END C++ spesific ******************/#endif /* WAR_THREAD_POOL_TASK_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -