warincrementcounter.h

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

H
95
字号
/** */#ifndef WAR_INCREMENT_COUNTER_H#define WAR_INCREMENT_COUNTER_H/* SYSTEM INCLUDES *//* PROJECT INCLUDES */#ifndef WAR_AUTO_LOCK#   include "WarAutoLock.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 __cplusplustemplate <class intT = war_uint64_t>class WarIncrementCounter{public:    typedef intT cnt_t;    // LIFECYCLE        /**    * Default constructor.    */    WarIncrementCounter() :    mCounter(0)    {    }    ~WarIncrementCounter()    {    }        // OPERATORS    // OPERATIONS    cnt_t GetNext()    {        WarAutoLock my_lock(mLock);        return ++mCounter;    }    std::string GetNextAsStr()    {        std::string buf;        return WarItoa(buf, GetNext());    }    // CALLBACK    // ACCESS    // INQUIRY    protected:private:    WarCriticalSection mLock;    cnt_t mCounter;};/* INLINE METHODS *//* EXTERNAL REFERENCES */#endif /* __cplusplus *//****************** END C++ spesific ******************/#endif  /* WAR_INCREMENT_COUNTER_H_ */

⌨️ 快捷键说明

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