Mac Developer Library

Developer

IOEventSource Class Reference

Options
Deployment Target:

On This Page
Language:

IOEventSource

Abstract class for all work-loop event sources. More...

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Not Applicable @import Kernel;

Availability


Available in OS X v10.0 and later.
  • Virtual member function used by IOWorkLoop for work scheduling.

    Declaration

    C++

    virtual bool checkForWork();

    Return Value

    Return true if this function needs to be called again before all its outstanding events have been processed.

    Discussion

    This function will be called to request a subclass to check its internal state for any work to do and then to call out the owner/action. If this event source never performs any work (e.g. IOCommandGate), this method should not be overridden. NOTE: This method is no longer declared pure virtual. A default implementation is provided in IOEventSource.

    Import Statement

  • Disable event source.

    Declaration

    C++

    virtual void disable();

    Discussion

    A subclass implementation is expected to respect the enabled state when checkForWork is called.

    Import Statement

  • Enable event source.

    Declaration

    C++

    virtual void enable();

    Discussion

    A subclass implementation is expected to respect the enabled state when checkForWork is called. Calling this function will cause the work-loop to be signalled so that a checkForWork is performed.

    Import Statement

  • Get'ter for $link action variable.

    Declaration

    C++

    virtual IOEventSource::Action getAction() const;

    Return Value

    value of action.

    Import Statement

  • Get'ter for $link eventChainNext variable.

    Declaration

    C++

    virtual IOEventSource *getNext() const;

    Return Value

    value of eventChainNext.

    Import Statement

  • Get'ter for $link workLoop variable.

    Declaration

    C++

    virtual IOWorkLoop *getWorkLoop() const;

    Return Value

    value of workLoop.

    Import Statement

  • Primary initialiser for the IOEventSource class.

    Declaration

    C++

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

    Parameters

    owner

    Owner of this instance of an event source. Used as the first parameter of the action callout. Owner will generally be an OSObject it doesn't have to be as no member functions will be called directly in it. It can just be a refcon for a client routine.

    action

    Pointer to C call out function. Action is a pointer to a C function that gets called when this event source has outstanding work. It will usually be called by the checkForWork member function. The first parameter of the action call out will always be the owner, this allows C++ member functions to be used as actions. Defaults to 0.

    Return Value

    true if the inherited classes and this instance initialise successfully.

    Import Statement

  • Get'ter for $link enable variable.

    Declaration

    C++

    virtual bool isEnabled() const;

    Return Value

    true if enabled.

    Import Statement

  • Convenience function for workLoop->onThread.

    Declaration

    C++

    virtual bool onThread() const;

    Return Value

    true if called on the work-loop thread.

    Import Statement

  • Set'ter for $link action variable.

    Declaration

    C++

    virtual void setAction( IOEventSource::Actionaction);

    Parameters

    action

    Pointer to a C function of type IOEventSource::Action.

    Import Statement

  • Set'ter for $link eventChainNext variable.

    Declaration

    C++

    virtual void setNext( IOEventSource *next);

    Parameters

    next

    Pointer to another IOEventSource instance.

    Import Statement

  • Set'ter for $link workLoop variable.

    Declaration

    C++

    virtual void setWorkLoop( IOWorkLoop *workLoop);

    Parameters

    workLoop

    Target work-loop of this event source instance. A subclass of IOWorkLoop that at least reacts to signalWorkAvailable() and onThread functions.

    Import Statement

Callbacks

  • Declaration

    C++

    typedef void ( *Action)( OSObject *owner, ...);

    Parameters

    owner

    Target of the function, can be used as a refcon. The owner is set during initialisation. Note if a C++ function was specified this parameter is implicitly the first paramter in the target member function's parameter list.

    Discussion

    Placeholder type for C++ function overloading discrimination. As the all event sources require an action and it has to be stored somewhere and be of some type, this is that type.

    Import Statement

    Availability

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

Constants

  • Declaration

    CPlusPlus

    #define IOEventSourceAction IOEventSource::Action

    Constants

    • IOEventSourceAction

      IOEventSourceAction

      Backward compatibilty define for the old non-class scoped type definition. See $link IOEventSource::Action

      Available in OS X v10.0 and later.

    Import Statement

  • Data Types

    • Declaration

      C++

      struct ExpansionData { #if IOKITSTATS struct IOEventSourceCounter *counter; #else void *iokitstatsReserved; #endif };

      Discussion

      This structure will be used to expand the capablilties of the IOEventSource in the future.

    Instance Variables

    • What is the work-loop for this event source.

      Declaration

      C++

      IOWorkLoop *workLoop;

    • Reserved for future use. (Internal use only)

      Declaration

      C++

      ExpansionData *reserved;

    • What ever the client wants to do, see $link setRefcon.

      Declaration

      C++

      void *refcon;

    • The owner object called when an event has been delivered.

      Declaration

      C++

      OSObject *owner;

    • The next event source in the event chain. nil at end of chain.

      Declaration

      C++

      IOEventSource *eventChainNext;

    • Is this event source enabled to deliver requests to the work-loop.

      Declaration

      C++

      bool enabled;

    • The action method called when an event has been delivered

      Declaration

      C++

      Action action;