IOEventSource



Member Functions

checkForWork

Abstract: Pure Virtual member function used by IOWorkLoop for work scheduling.
protected:

virtual bool checkForWork() = 0;

This function will be called to request a subclass to check it's internal state for any work to do and then to call out the owner/action.

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

disable

Abstract: Disable event source.
public:

virtual void disable();

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


enable

Abstract: Enable event source.
public:

virtual void enable();

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.


getAction

Abstract: Get'ter for $link action variable.
public:

virtual IOEventSource::Action getAction() const;

Result: value of action.

getNext

Abstract: Get'ter for $link eventChainNext variable.
protected:

virtual IOEventSource *getNext() const;

Result: value of eventChainNext.

getWorkLoop

Abstract: Get'ter for $link workLoop variable.
public:

virtual IOWorkLoop *getWorkLoop() const;

Result: value of workLoop.

init

Abstract: Primary initialiser for the IOEventSource class.
protected:

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

Parameters

NameDescription
ownerOwner 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.
actionPointer 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.
Result: true if the inherited classes and this instance initialise successfully.

isEnabled

Abstract: Get'ter for $link enable variable.
public:

virtual bool isEnabled() const;

Result: true if enabled.

onThread

Abstract: Convenience function for workLoop->onThread.
public:

virtual bool onThread() const;

Result: true if called on the work-loop thread.

setAction

Abstract: Set'ter for $link action variable.
public:

virtual void setAction(IOEventSource::Action action);

Parameters

NameDescription
actionPointer to a C function of type IOEventSource::Action.

setNext

Abstract: Set'ter for $link eventChainNext variable.
protected:

virtual void setNext(IOEventSource *next);

Parameters

NameDescription
nextPointer to another IOEventSource instance.

setWorkLoop

Abstract: Set'ter for $link workLoop variable.
protected:

virtual void setWorkLoop(IOWorkLoop *workLoop);

Parameters

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

Member Data

Action

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

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.

Parameters

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

action

protected:
 Action action;

The action method called when an event has been delivered


enabled

protected:
 bool enabled;

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


eventChainNext

protected:
 IOEventSource *eventChainNext;

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


owner

protected:
 OSObject *owner;

The owner object called when an event has been delivered.


refcon

protected:
 void *refcon;

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


workLoop

protected:
 IOWorkLoop *workLoop;

What is the work-loop for this event source.


#defines

IOEventSourceAction

#define IOEventSourceAction IOEventSource::Action

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


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