PulseNode Class Reference

Interface class for any object that can schedule Pulse() calls for itself via its PulseNodeManager. More...

#include <PulseNode.h>

Inheritance diagram for PulseNode:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 PulseNode ()
 Default constructor.
virtual ~PulseNode ()
 Destructor.
virtual uint64 GetPulseTime (uint64 now, uint64 prevResult)
 This method can be overridden to tell the PulseNodeManager when we would like to have our Pulse() method called.
virtual void Pulse (uint64 now, uint64 scheduledTime)
 Will be called at the time specified previously by GetPulseTime().
status_t PutPulseChild (PulseNode *child)
 Adds the given child into our set of child PulseNodes.
status_t RemovePulseChild (PulseNode *child)
 Attempts to remove the given child from our set of child PulseNodes.
void ClearPulseChildren ()
 Removes all children from our set of child PulseNodes.
bool ContainsPulseChild (PulseNode *child) const
 Returns true iff the given child is in our set of child PulseNodes.
uint64 GetScheduledPulseTime () const
 Returns when this object wants its call to Pulse() scheduled next, or MUSCLE_TIME_NEVER if it has no call to Pulse() currently scheduled.
uint64 GetCycleStartTime () const
 Returns the run-time at which the PulseNodeManager started calling our callbacks.
void SetSuggestedMaximumTimeSlice (uint64 maxUsecs)
 Sets the maximum number of microseconds that this class should allow its callback methods to execute for (relative to the cycle start time, as shown above).
uint64 GetSuggestedMaximumTimeSlice () const
 Returns the current suggested maximum duration of our time slice, or MUSCLE_TIME_NEVER if there is no suggested limit.
bool IsSuggestedTimeSliceExpired () const
 Convenience method -- returns true iff the current value of the run-time clock (GetRunTime64()) indicates that our suggested time slice has expired.

Protected Member Functions

void InvalidatePulseTime (bool clearPrevResult=true)
 Sets a flag to indicate that GetPulseTime() should be called on this object.

Friends

class PulseNodeManager

Detailed Description

Interface class for any object that can schedule Pulse() calls for itself via its PulseNodeManager.

(Typically the PulseNodeManager role is played by the ReflectServer class)

Definition at line 17 of file PulseNode.h.


Constructor & Destructor Documentation

virtual PulseNode::~PulseNode (  )  [virtual]

Destructor.

Does not delete any attached child PulseNodes.


Member Function Documentation

virtual uint64 PulseNode::GetPulseTime ( uint64  now,
uint64  prevResult 
) [virtual]

This method can be overridden to tell the PulseNodeManager when we would like to have our Pulse() method called.

This method is guaranteed to be called only during the following times:

  1. When the PulseNode is first probed by the PulseNodeManager
  2. Immediately after our Pulse() method has returned
  3. Soon after InvalidatePulseTime() has been called one or more times (InvalidatePulseTime() calls are merged together for efficiency)
Parameters:
now The current wall-clock time in microseconds, for convenience.
prevResult The value that this method returned the last time it was called. The very first time this method is called, this value will be passed in as MUSCLE_TIME_NEVER.
Returns:
Return MUSCLE_TIME_NEVER if you don't wish to schedule a future call to Pulse(); or return the time at which you want Pulse() to be called. Returning values less than or equal to (now) will cause Pulse() to be called as soon as possible. The default implementation always returns MUSCLE_TIME_NEVER.

Reimplemented in AbstractReflectSession, and RateLimitSessionIOPolicy.

virtual void PulseNode::Pulse ( uint64  now,
uint64  scheduledTime 
) [virtual]

Will be called at the time specified previously by GetPulseTime().

GetPulseTime() will be called again immediately after this call, to check if you want to schedule another Pulse() call for later. Default implementation is a no-op.

Parameters:
now The current wall-clock time-value in microseconds, for convenience.
scheduledTime The time this Pulse() call was scheduled to occur at, in microseconds, as previously returned by GetPulseTime(). Note that unless your computer is infinitely fast, this time will always be at least a bit less than (now), since there is a delay between when the program gets woken up to service the next Pulse() call, and when the call actually happens. (you may be able to use this value to compensate for the slippage, if it bothers you)

Reimplemented in AbstractReflectSession, and RateLimitSessionIOPolicy.

status_t PulseNode::PutPulseChild ( PulseNode child  ) 

Adds the given child into our set of child PulseNodes.

Any PulseNode in our set of children will have its pulsing needs taken care of by us, but it is not considered "owned" by this PulseNode--it will not be deleted when we are.

Parameters:
child The child to place into our set of child PulseNodes.
Returns:
B_NO_ERROR on success, or B_ERROR on failure (out of memory).

status_t PulseNode::RemovePulseChild ( PulseNode child  ) 

Attempts to remove the given child from our set of child PulseNodes.

Parameters:
child The child to remove
Returns:
B_NO_ERROR on success, or B_ERROR on failure (child wasn't in our set)

bool PulseNode::ContainsPulseChild ( PulseNode child  )  const [inline]

Returns true iff the given child is in our set of child PulseNodes.

Parameters:
child the child to look for.

Definition at line 84 of file PulseNode.h.

References _parent.

uint64 PulseNode::GetCycleStartTime (  )  const [inline]

Returns the run-time at which the PulseNodeManager started calling our callbacks.

Useful for any object that wants to limit the maximum duration of its timeslice in the PulseNodeManager's event loop.

Definition at line 95 of file PulseNode.h.

void PulseNode::SetSuggestedMaximumTimeSlice ( uint64  maxUsecs  )  [inline]

Sets the maximum number of microseconds that this class should allow its callback methods to execute for (relative to the cycle start time, as shown above).

Note that this value is merely a suggestion; it remains up to the subclass's callback methods to ensure that the suggestion is actually followed.

Parameters:
maxUsecs Maximum number of microseconds that the time slice should last for. If set to MUSCLE_TIME_NEVER, that indicates that there is no suggested limit.

Definition at line 104 of file PulseNode.h.

uint64 PulseNode::GetSuggestedMaximumTimeSlice (  )  const [inline]

Returns the current suggested maximum duration of our time slice, or MUSCLE_TIME_NEVER if there is no suggested limit.

Default value is MUSCLE_TIME_NEVER.

Definition at line 109 of file PulseNode.h.

bool PulseNode::IsSuggestedTimeSliceExpired (  )  const [inline]

Convenience method -- returns true iff the current value of the run-time clock (GetRunTime64()) indicates that our suggested time slice has expired.

This method is cheap to call often.

Definition at line 115 of file PulseNode.h.

void PulseNode::InvalidatePulseTime ( bool  clearPrevResult = true  )  [protected]

Sets a flag to indicate that GetPulseTime() should be called on this object.

Call this whenever you've decided to reschedule your pulse time outside of a Pulse() event.

Parameters:
clearPrevResult if true, this call will also clear the stored prevResult value, so that the next time GetPulseTime() is called, prevResult is passed in as MUSCLE_TIME_NEVER. If false, the prevResult value will be left alone.

Referenced by AbstractReflectSession::SetAutoReconnectDelay().


The documentation for this class was generated from the following file:
Generated on Thu Jun 5 17:48:22 2008 for MUSCLE by  doxygen 1.5.1