1/* 2 File: CTimer.h 3 4*/ 5 6#ifndef __CTimer__ 7#define __CTimer__ 8 9#include "IrDATypes.h" 10#include <IOKit/IOWorkLoop.h> 11#include <IOKit/IOTimerEventSource.h> 12#include "IrDATimerEventSource.h" 13 14class CTimer; 15 16class CTimer : public OSObject 17{ 18 OSDeclareDefaultStructors(CTimer); 19 20public: 21 typedef IrDATimerEventSource::Action Action; // defines CTimer::Action 22 23 static CTimer *cTimer(IOWorkLoop *work, OSObject *owner, Action callback); 24 Boolean init(IOWorkLoop *work, OSObject *owner, Action callback); 25 void free(void); 26 27 void StartTimer(TTimeout delay, UInt32 sig); // ms delay if positive, else usec delay 28 void StopTimer(void); 29 30 UInt32 GetSignature(void); 31 IrDATimerEventSource *GetIOTimer(void); 32 static void grim_reaper(thread_call_param_t param0, thread_call_param_t param1); 33 34private: 35 static void timeout(OSObject *owner, IrDATimerEventSource *sender); 36 UInt32 fSig; 37 IrDATimerEventSource *fTimerSrc; // the i/o kit timer 38 IOWorkLoop *fWorkLoop; // workloop we run on 39 OSObject *fOwner; // the owner (IrGlue usually) 40 Action fCallback; // the callback in our client 41 thread_call_t fGrimReaper; // extra thread to nuke ourselves 42 Boolean fBusy; // true if timer is set 43}; 44 45inline UInt32 CTimer::GetSignature() { return fSig; } 46inline IrDATimerEventSource * CTimer::GetIOTimer() { return fTimerSrc; } 47 48 49#endif // __CTimer__ 50 51