IOTimerEventSource
Member Functions
Abstract: Disable any outstanding calls to this event source.
public:
virtual void cancelTimeout();
Clear down any oustanding calls. By the time this function completes it is guaranteed that the action will not be called again.
Abstract: Have to implement it is mandatory in $link IOEventSource, but IOTimerEventSources don't actually use this work-loop mechanism.
protected:
virtual bool checkForWork();
Abstract: Disable a timed callout.
public:
virtual void disable();
When disable returns the action will not be called until the next time enable(qv) is called.
Abstract: Enables a call to the action.
public:
virtual void enable();
Allows the action function to be called. If the timer event source was disabled while a call was outstanding and the call wasn't cancelled then it will be rescheduled. So a disable/enable pair will disable calls from this event source.
Abstract: Sub-class implementation of free method, frees calloutEntry
protected:
virtual void free();
Abstract: Initializes the timer with an owner, and a handler to call when the timeout expires.
public:
virtual bool init(OSObject *owner, Action action = 0);
Abstract: Setup a callback at after the delay in decrementer ticks. See wakeAtTime(AbsoluteTime).
public:
virtual IOReturn setTimeout(AbsoluteTime interval);
Parameters
Name | Description |
interval | Delay from now to wake up in decrementer ticks. |
Result: kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.
Abstract: Setup a callback at after the delay in decrementer ticks. See wakeAtTime(AbsoluteTime).
public:
virtual IOReturn setTimeout(mach_timespec_t interval);
Parameters
Name | Description |
interval | Delay from now to wake up. |
Result: kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.
Abstract: Setup a callback at after the delay in some unit. See wakeAtTime(AbsoluteTime).
public:
virtual IOReturn setTimeout(UInt32 interval,
UInt32 scale_factor = kNanosecondScale);
Parameters
Name | Description |
interval | Delay from now to wake up in some defined unit. |
scale_factor | Define the unit of interval, default to nanoseconds. |
Result: kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.
Abstract: Set's timeout as the function of calloutEntry.
protected:
virtual void setTimeoutFunc();
IOTimerEventSource is based upon the kern/thread_call.h APIs currently. This function allocates the calloutEntry member variable by using thread_call_allocate(timeout, this). If you need to write your own subclass of IOTimerEventSource you probably should override this method to allocate an entry that points to your own timeout routine.
Abstract: Setup a callback at after the delay in milliseconds. See wakeAtTime(AbsoluteTime).
public:
virtual IOReturn setTimeoutMS(UInt32 ms);
Parameters
Name | Description |
interval | Delay from now to wake up, time in milliseconds. |
Result: kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.
Abstract: Setup a callback at after the delay in scheduler ticks. See wakeAtTime(AbsoluteTime).
public:
virtual IOReturn setTimeoutTicks(UInt32 ticks);
Parameters
Name | Description |
interval | Delay from now to wake up, in scheduler ticks, whatever that may be. |
Result: kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.
Abstract: Setup a callback at after the delay in microseconds. See wakeAtTime(AbsoluteTime).
public:
virtual IOReturn setTimeoutUS(UInt32 us);
Parameters
Name | Description |
interval | Delay from now to wake up, time in microseconds. |
Result: kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.
Abstract: Function that routes the call from the OS' timeout mechanism into a work-loop context.
protected:
static void timeout(void *self);
timeout will normally not be called nor overridden by a subclass. If the event source is enabled then close the work-loop's gate and call the action routine.
Parameters
Name | Description |
self | This argument will be cast to an IOTimerEventSource. |
Abstract: Allocates and returns an initialized timer instance.
public:
static IOTimerEventSource * timerEventSource(OSObject *owner, Action action = 0);
Abstract: Setup a callback at this absolute time. See wakeAtTime(AbsoluteTime).
public:
virtual IOReturn wakeAtTime(mach_timespec_t abstime);
Parameters
Name | Description |
abstime | mach_timespec_t of the desired callout time. |
Result: kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.
Abstract: Setup a callback at this absolute time.
public:
virtual IOReturn wakeAtTime(AbsoluteTime abstime);
Starts the timer, which will expire at abstime. After it expires, the timer will call the 'action' registered in the init() function. This timer is not periodic, a further call is needed to reset and restart the timer after it expires.
Parameters
Name | Description |
abstime | Absolute Time when to wake up, counted in 'decrementer' units and starts at zero when system boots. |
Result: kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared by init or IOEventSource::setAction (qqv).
Abstract: Setup a callback at this absolute time. See wakeAtTime(AbsoluteTime).
public:
virtual IOReturn wakeAtTime(UInt32 abstime,
UInt32 scale_factor = kNanosecondScale);
Parameters
Name | Description |
abstime | Time to wake up in some unit. |
scale_factor | Define the unit of abstime, default to nanoseconds. |
Result: kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.
Abstract: Setup a callback at this absolute time. See wakeAtTime(AbsoluteTime).
public:
virtual IOReturn wakeAtTimeMS(UInt32 ms);
Parameters
Name | Description |
abstime | Time to wake up in milliseconds. |
Result: kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.
Abstract: Setup a callback at this absolute time. See wakeAtTime(AbsoluteTime).
public:
virtual IOReturn wakeAtTimeTicks(UInt32 ticks);
Parameters
Name | Description |
abstime | Time to wake up in scheduler quantums, whatever that is? |
Result: kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.
Abstract: Setup a callback at this absolute time. See wakeAtTime(AbsoluteTime).
public:
virtual IOReturn wakeAtTimeUS(UInt32 us);
Parameters
Name | Description |
abstime | Time to wake up in microseconds. |
Result: kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.
Member Data
public:typedef void (*Action)(OSObject *owner, IOTimerEventSource *sender);
'C' Function pointer defining the callout routine of this event source.
Parameters
Name | Description |
owner | Owning target object. Note by a startling coincidence the first parameter in a C callout is currently used to define the target of a C++ member function. |
sender | The object that timed out. |
public:
enum {
kNanosecondScale = 1,
kMicrosecondScale = 1000,
kMillisecondScale = 1000 * 1000
};
Used when a scale_factor parameter is required to define a unit of time.
Constants
Name | Description |
kNanosecondScale | Scale factor for nanosecond based times. |
kMicrosecondScale | Scale factor for microsecond based times. |
kMillisecondScale | Scale factor for millisecond based times. |
protected:
AbsoluteTime abstime;
time to wake up next, see enable.
protected:
void *calloutEntry;
thread_call entry for preregistered thread callouts
© 2000 Apple Computer, Inc. (Last Updated 2/23/2000)