wartimer.h

来自「ftpserver very good sample」· C头文件 代码 · 共 134 行

H
134
字号
/** */#ifndef WAR_TIMER_H#define WAR_TIMER_H/* SYSTEM INCLUDES */#ifndef WAR_INCLUDED_SET#   define WAR_INCLUDED_SET#   include <set>#endif#ifndef WAR_ASSERT_H_INCLUDED#   define WAR_ASSERT_H_INCLUDED#   include <assert.h>#endif/* PROJECT INCLUDES */#ifndef WAR_TIMER_EVENT_H#   include "WarTimerEvent.h"#endif#ifndef WAR_THREAD_H#   include "WarThread.h"#endif#ifndef WAR_THREAD_POOL_H#   include "WarThreadPool.h"#endif/* LOCAL INCLUDES *//* FORWARD REFERENCES */#ifdef __cplusplusextern "C" {#endif/****************** BEGIN OLD STYLE C spesific ********//****************** END OLD STYLE C spesific **********/#ifdef __cplusplus }#endif/****************** BEGIN C++ spesific ****************/#ifdef __cplusplusclass WarTimer : public WarThread{public:    typedef std::multiset<war_timer_event_ptr_t> events_t;    // LIFECYCLE        /**    * Default constructor.    */    WarTimer();        /**    * Destructor.    */    ~WarTimer();        // OPERATORS    // OPERATIONS                               void AddEvent(war_timer_event_ptr_t& newEvent)        throw(WarException);        void KillEvent(war_timer_event_ptr_t& oldEvent)        throw(WarException);        virtual void SetExitFlag();    virtual void SetAbortFlag()    {        assert(false); // Use SetExitFlag()    }        // ACCESS    const WarTime GetNextEventTime();    static WarTimer& GetTimer() throw(WarException);    static bool IsTimerActive()    {        return spThis != NULL;    }    // INQUIRY    protected:        void Run();    friend class WarTimerEventTask;    // Called by WarTimer and WarTimerEventTask    void OnCompleted(war_timer_event_ptr_t& my_event);    friend class WarShutdownEngine;    static void OnShutdown(war_cptr_t ptr);private:    events_t mEvents;    WarCriticalSection mLock;    WarThreadEvent mSignal;    WarThreadPool mPool;    static WarTimer *spThis;};/* INLINE METHODS *//* EXTERNAL REFERENCES */typedef WarPtrWrapper<WarTimer> war_timer_ptr_t;#endif /* __cplusplus *//****************** END C++ spesific ******************/#endif  /* WAR_TIMER_H_ */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?