1 2#include <IOKit/IOLib.h> 3#include "IrDATimerEventSource.h" 4 5#include "IrDALog.h" 6#include "IrDADebugging.h" 7 8// todo: merge with ctimer object 9 10#if (hasTracing > 0) 11 12enum IrLogCodes 13{ 14 kLogNew = 1, 15 kLogFree, 16 kLogCancel 17}; 18 19static 20EventTraceCauseDesc IrLogEvents[] = { 21 {kLogNew, "IrDATimer: new, obj="}, 22 {kLogFree, "IrDATimer: free, obj="}, 23 {kLogCancel, "IrDATimer: safe cancel, cancel worked="} 24}; 25 26#define XTRACE(x, y, z) IrDALogAdd( x, y, (uintptr_t)z & 0xffff, IrLogEvents, true ) 27 28#else 29#define XTRACE(x,y,z) ((void)0) 30#endif 31 32#define super IOTimerEventSource 33 34 OSDefineMetaClassAndStructors(IrDATimerEventSource, IOTimerEventSource); 35 36// 37// returns true if the cancel worked, else it 38// wasn't found to remove. 39// 40Boolean IrDATimerEventSource::SafeCancelTimeout() 41{ 42 Boolean cancel_ok; 43 44 AbsoluteTime_to_scalar(&abstime) = 0; 45 // thread_call_cancel returns true if it was able to dequeue the thread 46 cancel_ok = thread_call_cancel((thread_call_t) calloutEntry); 47 XTRACE(kLogCancel, 0, cancel_ok); 48 return cancel_ok; 49} 50 51/* static */ 52IrDATimerEventSource * 53IrDATimerEventSource::timerEventSource(OSObject *inOwner, Action inAction) 54{ 55 IrDATimerEventSource *me = new IrDATimerEventSource; 56 XTRACE(kLogNew, 0, me); 57 58 // note: we don't have an init, so pass it up to IOTimerEventSource 59 if (me && !me->init(inOwner, (super::Action)inAction)) { 60 me->free(); 61 return 0; 62 } 63 64 return me; 65} 66