ctimer.h

来自「简单的linux下的timer类」· C头文件 代码 · 共 52 行

H
52
字号

#ifndef __CTIMER_H__
#define __CTIMER_H__


#ifdef __cplusplus
extern "C"{
#endif

typedef void (*pfTimerCallFunc)(int);

typedef struct tagTimer {    
    int total_time;   
    int left_time;   
    pfTimerCallFunc pfFunc;        
    struct tagTimer *pNextNode;
}TIMER_S;    

/* 本类只能精确到秒级 */
class Timer
{
    public:
        Timer();
        ~Timer();
        int SetTimer(int iSec,pfTimerCallFunc pfFunc);
        void Start();
        void ReStart();
        void Stop();
        void Clear();

    private:
        static void HandlNode(TIMER_S *Node, int iFlag);
        static void Catch_Alarm(int iSig);
        static int SetFlag();
        //static void *Trigger(void*p);
        
        static int _iFlag;
        static TIMER_S *_pTimeListHead;
        
        
        TIMER_S *_pTimerNodeAddr;
};



#ifdef __cplusplus
}
#endif

#endif

⌨️ 快捷键说明

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