IOTimerEventSource



Member Functions

cancelTimeout

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.


checkForWork

Abstract: Have to implement it is mandatory in $link IOEventSource, but IOTimerEventSources don't actually use this work-loop mechanism.
protected:

virtual bool checkForWork();


disable

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.


enable

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.


free

Abstract: Sub-class implementation of free method, frees calloutEntry
protected:

virtual void free();


init

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);


setTimeout

Abstract: Setup a callback at after the delay in decrementer ticks. See wakeAtTime(AbsoluteTime).
public:

virtual IOReturn setTimeout(AbsoluteTime interval);

Parameters

NameDescription
intervalDelay from now to wake up in decrementer ticks.
Result: kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.

setTimeout

Abstract: Setup a callback at after the delay in decrementer ticks. See wakeAtTime(AbsoluteTime).
public:

virtual IOReturn setTimeout(mach_timespec_t interval);

Parameters

NameDescription
intervalDelay from now to wake up.
Result: kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.

setTimeout

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

NameDescription
intervalDelay from now to wake up in some defined unit.
scale_factorDefine the unit of interval, default to nanoseconds.
Result: kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.

setTimeoutFunc

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.


setTimeoutMS

Abstract: Setup a callback at after the delay in milliseconds. See wakeAtTime(AbsoluteTime).
public:

virtual IOReturn setTimeoutMS(UInt32 ms);

Parameters

NameDescription
intervalDelay from now to wake up, time in milliseconds.
Result: kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.

setTimeoutTicks

Abstract: Setup a callback at after the delay in scheduler ticks. See wakeAtTime(AbsoluteTime).
public:

virtual IOReturn setTimeoutTicks(UInt32 ticks);

Parameters

NameDescription
intervalDelay 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.

setTimeoutUS

Abstract: Setup a callback at after the delay in microseconds. See wakeAtTime(AbsoluteTime).
public:

virtual IOReturn setTimeoutUS(UInt32 us);

Parameters

NameDescription
intervalDelay from now to wake up, time in microseconds.
Result: kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.

timeout

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

NameDescription
selfThis argument will be cast to an IOTimerEventSource.

timerEventSource

Abstract: Allocates and returns an initialized timer instance.
public:

static IOTimerEventSource * timerEventSource(OSObject *owner, Action action = 0);


wakeAtTime

Abstract: Setup a callback at this absolute time. See wakeAtTime(AbsoluteTime).
public:

virtual IOReturn wakeAtTime(mach_timespec_t abstime);

Parameters

NameDescription
abstimemach_timespec_t of the desired callout time.
Result: kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.

wakeAtTime

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

NameDescription
abstimeAbsolute 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).

wakeAtTime

Abstract: Setup a callback at this absolute time. See wakeAtTime(AbsoluteTime).
public:

virtual IOReturn wakeAtTime(UInt32 abstime, UInt32 scale_factor = kNanosecondScale);

Parameters

NameDescription
abstimeTime to wake up in some unit.
scale_factorDefine the unit of abstime, default to nanoseconds.
Result: kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.

wakeAtTimeMS

Abstract: Setup a callback at this absolute time. See wakeAtTime(AbsoluteTime).
public:

virtual IOReturn wakeAtTimeMS(UInt32 ms);

Parameters

NameDescription
abstimeTime to wake up in milliseconds.
Result: kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.

wakeAtTimeTicks

Abstract: Setup a callback at this absolute time. See wakeAtTime(AbsoluteTime).
public:

virtual IOReturn wakeAtTimeTicks(UInt32 ticks);

Parameters

NameDescription
abstimeTime to wake up in scheduler quantums, whatever that is?
Result: kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.

wakeAtTimeUS

Abstract: Setup a callback at this absolute time. See wakeAtTime(AbsoluteTime).
public:

virtual IOReturn wakeAtTimeUS(UInt32 us);

Parameters

NameDescription
abstimeTime to wake up in microseconds.
Result: kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.

Member Data

Action

public:typedef void (*Action)(OSObject *owner, IOTimerEventSource *sender);

'C' Function pointer defining the callout routine of this event source.

Parameters

NameDescription
ownerOwning 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.
senderThe object that timed out.

Scale

public:
  enum  {
  kNanosecondScale  =  1,
  kMicrosecondScale  =  1000,
  kMillisecondScale  =  1000  *  1000
  };

Used when a scale_factor parameter is required to define a unit of time.

Constants

NameDescription
kNanosecondScaleScale factor for nanosecond based times.
kMicrosecondScaleScale factor for microsecond based times.
kMillisecondScaleScale factor for millisecond based times.

abstime

protected:
 AbsoluteTime abstime;

time to wake up next, see enable.


calloutEntry

protected:
 void *calloutEntry;

thread_call entry for preregistered thread callouts


© 2000 Apple Computer, Inc. — (Last Updated 2/23/2000)