Mac Developer Library

Developer

IOTimerEventSource Class Reference

Options
Deployment Target:

On This Page
Language:

IOTimerEventSource

Time based event source mechanism. More...

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Not Applicable @import Kernel;

Availability


Available in OS X v10.0 and later.
  • Disable any outstanding calls to this event source.

    Declaration

    C++

    virtual void cancelTimeout();

    Discussion

    Clear down any oustanding calls. By the time this function completes it is guaranteed that the action will not be called again.

    Import Statement

  • Disable a timed callout.

    Declaration

    C++

    virtual void disable();

    Discussion

    When disable returns the action will not be called until the next time enable(qv) is called.

    Import Statement

  • Enables a call to the action.

    Declaration

    C++

    virtual void enable();

    Discussion

    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.

    Import Statement

  • Sub-class implementation of free method, frees calloutEntry

    Declaration

    C++

    virtual void free();

    Import Statement

  • Initializes the timer with an owner, and a handler to call when the timeout expires.

    Declaration

    C++

    virtual bool init( OSObject *owner, Action action = 0);

    Parameters

    owner
    action

    Import Statement

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

    Declaration

    C++

    virtual IOReturn setTimeout( AbsoluteTimeinterval);

    Parameters

    interval

    Delay from now to wake up in decrementer ticks.

    Return Value

    kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.

    Import Statement

  • Setup a callback at after the delay in some unit. See wakeAtTime(AbsoluteTime).

    Declaration

    C++

    virtual IOReturn setTimeout( UInt32interval, UInt32 scale_factor = scale_factor);

    Parameters

    interval

    Delay from now to wake up in some defined unit.

    scale_factor

    Define the unit of interval, default to nanoseconds.

    Return Value

    kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.

    Import Statement

  • Set's timeout as the function of calloutEntry.

    Declaration

    C++

    virtual void setTimeoutFunc();

    Discussion

    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.

    Import Statement

  • Setup a callback at after the delay in milliseconds. See wakeAtTime(AbsoluteTime).

    Declaration

    C++

    virtual IOReturn setTimeoutMS( UInt32interval);

    Parameters

    interval

    Delay from now to wake up, time in milliseconds.

    Return Value

    kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.

    Import Statement

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

    Declaration

    C++

    virtual IOReturn setTimeoutTicks( UInt32interval);

    Parameters

    interval

    Delay from now to wake up, in scheduler ticks, whatever that may be.

    Return Value

    kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.

    Import Statement

  • Setup a callback at after the delay in microseconds. See wakeAtTime(AbsoluteTime).

    Declaration

    C++

    virtual IOReturn setTimeoutUS( UInt32interval);

    Parameters

    interval

    Delay from now to wake up, time in microseconds.

    Return Value

    kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.

    Import Statement

  • Function that routes the call from the OS' timeout mechanism into a work-loop context.

    Declaration

    C++

    static void timeout( void *self);

    Parameters

    self

    This argument will be cast to an IOTimerEventSource.

    Discussion

    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.

    Import Statement

  • Allocates and returns an initialized timer instance.

    Declaration

    C++

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

    Parameters

    owner
    action

    Import Statement

  • Setup a callback at this absolute time.

    Declaration

    C++

    virtual IOReturn wakeAtTime( AbsoluteTimeabstime);

    Parameters

    abstime

    Absolute Time when to wake up, counted in 'decrementer' units and starts at zero when system boots.

    Return Value

    kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared by init or IOEventSource::setAction (qqv).

    Discussion

    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.

    Import Statement

  • Setup a callback at this absolute time. See wakeAtTime(AbsoluteTime).

    Declaration

    C++

    virtual IOReturn wakeAtTime( UInt32abstime, UInt32 scale_factor = scale_factor);

    Parameters

    abstime

    Time to wake up in some unit.

    scale_factor

    Define the unit of abstime, default to nanoseconds.

    Return Value

    kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.

    Import Statement

  • Setup a callback at this absolute time. See wakeAtTime(AbsoluteTime).

    Declaration

    C++

    virtual IOReturn wakeAtTimeMS( UInt32abstime);

    Parameters

    abstime

    Time to wake up in milliseconds.

    Return Value

    kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.

    Import Statement

  • Setup a callback at this absolute time. See wakeAtTime(AbsoluteTime).

    Declaration

    C++

    virtual IOReturn wakeAtTimeTicks( UInt32abstime);

    Parameters

    abstime

    Time to wake up in scheduler quantums, whatever that is?

    Return Value

    kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.

    Import Statement

  • Setup a callback at this absolute time. See wakeAtTime(AbsoluteTime).

    Declaration

    C++

    virtual IOReturn wakeAtTimeUS( UInt32abstime);

    Parameters

    abstime

    Time to wake up in microseconds.

    Return Value

    kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared.

    Import Statement

Callbacks

  • Declaration

    C++

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

    Parameters

    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.

    Discussion

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

    Import Statement

    Availability

    Available in OS X v10.0 through OS X v10.5.

Data Types

  • Declaration

    C++

    struct ExpansionData { SInt32 calloutGeneration; IOWorkLoop *workLoop; };

    Discussion

    This structure is private to the IOTimerEventSource implementation.

Instance Variables

  • Reserved for future use. (Internal use only)

    Declaration

    C++

    ExpansionData *reserved;

  • thread_call entry for preregistered thread callouts

    Declaration

    C++

    void *calloutEntry;

  • time to wake up next, see enable.

    Declaration

    C++

    AbsoluteTime abstime;