MessageIOGateway Class Reference

A "gateway" object that knows how to send/receive Messages over a wire, via a provided DataIO object. More...

#include <MessageIOGateway.h>

Inheritance diagram for MessageIOGateway:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 MessageIOGateway (int32 outgoingEncoding=MUSCLE_MESSAGE_ENCODING_DEFAULT)
 Constructor.
virtual ~MessageIOGateway ()
 Destructor.
virtual bool HasBytesToOutput () const
 Should return true if this gateway has bytes that are queued up and waiting to be sent across the wire.
virtual void Reset ()
 This method must resets the gateway's encoding and decoding state to its default state.
void SetAboutToFlattenMessageCallback (MessageFlattenedCallback cb, void *ud)
 Lets you specify a function that will be called every time an outgoing Message is about to be flattened by this gateway.
void SetMessageFlattenedCallback (MessageFlattenedCallback cb, void *ud)
 Lets you specify a function that will be called every time an outgoing Message has been flattened by this gateway.
void SetMessageUnflattenedCallback (MessageFlattenedCallback cb, void *ud)
 Lets you specify a function that will be called every time an incoming Message has been unflattened by this gateway.
void SetMaxIncomingMessageSize (uint32 maxBytes)
 Lets you specify the maximum allowable size for an incoming flattened Message.
uint32 GetMaxIncomingMessageSize () const
 Returns the current maximum incoming message size, as was set above.
int32 GetOutgoingEncoding () const
 Returns our encoding method, as specified in the constructor or via SetOutgoingEncoding().
void SetOutgoingEncoding (int32 ec)
 Call this to change the encoding this gateway applies to outgoing Messages.
virtual status_t ExecuteSynchronousMessaging (AbstractGatewayMessageReceiver *optReceiver, uint64 timeoutPeriod=MUSCLE_TIME_NEVER)
 Overwritten to augment AbstractMessageIOGateway::ExecuteSynchronousMessaging() with some additional logic that prepends a PR_COMMAND_PING to the outgoing Message queue and then makes sure that ExecuteSynchronousMessaging() doesn't return until the corresponding PR_COMMAND_PONG is received.
status_t AddOutgoingMessage (const MessageRef &messageRef)
 Appends the given message reference to the end of our list of outgoing messages to send.
int32 DoOutput (uint32 maxBytes=MUSCLE_NO_LIMIT)
 Writes some of our outgoing message bytes to the wire.
int32 DoInput (AbstractGatewayMessageReceiver &receiver, uint32 maxBytes=MUSCLE_NO_LIMIT)
 Reads some more incoming message bytes from the wire.
virtual bool IsReadyForInput () const
 Should return true if this gateway is willing to receive from bytes from the wire.
virtual uint64 GetOutputStallLimit () const
 Returns the number of microseconds that output to this gateway's client should be allowed to stall for.
virtual void Shutdown ()
 Shuts down the gateway.
void SetFlushOnEmpty (bool flush)
 By default, the AbstractMessageIOGateway calls Flush() on its DataIO's output stream whenever the last outgoing message in the outgoing message queue is sent.
bool GetFlushOnEmpty () const
 Accessor for the current state of the FlushOnEmpty flag.
Queue< MessageRef > & GetOutgoingMessageQueue ()
 Returns A reference to our outgoing messages queue.
const Queue< MessageRef > & GetOutgoingMessageQueue () const
 Returns A const reference to our outgoing messages queue.
void SetDataIO (const DataIORef &ref)
 Installs (ref) as the DataIO object we will use for our I/O.
const DataIORefGetDataIO () const
 As above, but returns a reference instead of the raw pointer.
bool IsHosed () const
 Returns true iff we are hosed--that is, we've experienced an unrecoverable error.
void IncrementRefCount () const
 Increments the counter and returns true iff the new value is zero.
bool DecrementRefCount () const
 Decrements the counter and returns true iff the new value is zero.
void SetManager (AbstractObjectManager *manager)
 Sets the recycle-pointer for this object.
AbstractObjectManagerGetManager () const
 Returns this object's current recyler pointer.
uint32 GetRefCount () const
 Returns this object's current reference count.
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

virtual int32 DoOutputImplementation (uint32 maxBytes=MUSCLE_NO_LIMIT)
 Writes some of our outgoing message bytes to the wire.
virtual int32 DoInputImplementation (AbstractGatewayMessageReceiver &receiver, uint32 maxBytes=MUSCLE_NO_LIMIT)
 Reads some more incoming message bytes from the wire.
virtual ByteBufferRef FlattenMessage (const MessageRef &msgRef, uint8 *header) const
 Flattens a specified Message object into a flat ByteBuffer object.
virtual MessageRef UnflattenMessage (const ByteBufferRef &bufRef, const uint8 *header) const
 Unflattens a specified ByteBuffer object back into a MessageRef object.
virtual uint32 GetHeaderSize () const
 Returns the size of the pre-flattened-message header section, in bytes.
virtual int32 GetBodySize (const uint8 *header) const
 Must Extract and returns the buffer body size from the given header.
virtual bool IsStillAwaitingSynchronousMessagingReply () const
 Overridden to return true until our PONG Message is received back.
virtual void SynchronousMessageReceivedFromGateway (const MessageRef &msg, void *userData, AbstractGatewayMessageReceiver &r)
 Overridden to filter out our PONG Message and pass everything else on to (r).
status_t EnsureBufferSize (uint8 **bufPtr, uint32 *bufSize, uint32 desiredSize, uint32 copySize)
 Convenience method to allocate or reallocate a buffer.
void FreeLargeBuffer (uint8 **bufPtr, uint32 *bufSize)
 Convenience method; frees the given buffer and resets it to NULL, if the buffer is greater than 10 kilobytes big.
void SetHosed ()
 Call this method to flag this gateway as hosed--that is, to say that an unrecoverable error has occurred.
virtual void SynchronousAfterMessageReceivedFromGateway (const MessageRef &msg, void *userData, AbstractGatewayMessageReceiver &r)
 Called by ExecuteSynchronousMessaging() after a Message is received.
virtual void SynchronousBeginMessageReceivedFromGatewayBatch (AbstractGatewayMessageReceiver &r)
 Called by ExecuteSynchronousMessaging() when a batch of Messages is about to be received.
virtual void SynchronousEndMessageReceivedFromGatewayBatch (AbstractGatewayMessageReceiver &r)
 Called by ExecuteSynchronousMessaging() when all Messages in a batch have been received.
void InvalidatePulseTime (bool clearPrevResult=true)
 Sets a flag to indicate that GetPulseTime() should be called on this object.

Classes

class  TransferBuffer

Detailed Description

A "gateway" object that knows how to send/receive Messages over a wire, via a provided DataIO object.

May be subclassed to change the byte-level protocol, or used as-is if the default protocol is desired. If ZLib compression is desired, be sure to compile with -DMUSCLE_ENABLE_ZLIB_ENCODING

The default protocol format used by this class is:

  1. 4 bytes (uint32) indicating the flattened size of the message
  2. 4 bytes (uint32) indicating the encoding type (should always be MUSCLE_MESSAGE_ENCODING_DEFAULT for now)
  3. n bytes of flattened Message (where n is the value specified in 1)
  4. goto 1 ...

An example flattened Message byte structure is provided at the bottom of the MessageIOGateway.h header file.

Definition at line 51 of file MessageIOGateway.h.


Constructor & Destructor Documentation

MessageIOGateway::MessageIOGateway ( int32  outgoingEncoding = MUSCLE_MESSAGE_ENCODING_DEFAULT  ) 

Constructor.

Parameters:
outgoingEncoding The byte-stream format the message should be encoded into. Should be one of the MUSCLE_MESSAGE_ENCODING_* values. Default is MUSCLE_MESSAGE_ENCODING_DEFAULT, meaning that no compression will be done. Note that to use any of the MUSCLE_MESSAGE_ENCODING_ZLIB_* encodings, you MUST have defined the compiler symbol -DMUSCLE_ENABLE_ZLIB_ENCODING.

virtual MessageIOGateway::~MessageIOGateway (  )  [virtual]

Destructor.

Deletes the held DataIO object.


Member Function Documentation

virtual bool MessageIOGateway::HasBytesToOutput (  )  const [virtual]

Should return true if this gateway has bytes that are queued up and waiting to be sent across the wire.

Should return false if there are no bytes ready to send, or if the connection has been closed or hosed.

Implements AbstractMessageIOGateway.

virtual void MessageIOGateway::Reset (  )  [virtual]

This method must resets the gateway's encoding and decoding state to its default state.

Any partially completed sends and receives should be cleared, so that the gateway is ready to send and receive fresh data streams. Default implementation clears the "hosed" flag and clears the outgoing-Messages queue. Subclasses should override this to reset their parse-state variables appropriately too.

Reimplemented from AbstractMessageIOGateway.

void MessageIOGateway::SetAboutToFlattenMessageCallback ( MessageFlattenedCallback  cb,
void *  ud 
) [inline]

Lets you specify a function that will be called every time an outgoing Message is about to be flattened by this gateway.

You may alter the Message at this time, if you need to.

Parameters:
cb Callback function to call.
ud User data; set this to any value you like.

Definition at line 81 of file MessageIOGateway.h.

void MessageIOGateway::SetMessageFlattenedCallback ( MessageFlattenedCallback  cb,
void *  ud 
) [inline]

Lets you specify a function that will be called every time an outgoing Message has been flattened by this gateway.

Parameters:
cb Callback function to call.
ud User data; set this to any value you like.

Definition at line 89 of file MessageIOGateway.h.

void MessageIOGateway::SetMessageUnflattenedCallback ( MessageFlattenedCallback  cb,
void *  ud 
) [inline]

Lets you specify a function that will be called every time an incoming Message has been unflattened by this gateway.

Parameters:
cb Callback function to call.
ud User data; set this to any value you like.

Definition at line 97 of file MessageIOGateway.h.

void MessageIOGateway::SetMaxIncomingMessageSize ( uint32  maxBytes  )  [inline]

Lets you specify the maximum allowable size for an incoming flattened Message.

Doing so lets you limit the amount of memory a remote computer can cause your computer to attempt to allocate. Default max message size is MUSCLE_NO_LIMIT (or about 4 gigabytes)

Parameters:
maxBytes New incoming message size limit, in bytes.

Definition at line 106 of file MessageIOGateway.h.

void MessageIOGateway::SetOutgoingEncoding ( int32  ec  )  [inline]

Call this to change the encoding this gateway applies to outgoing Messages.

Note that the encoding change will take place starting with the next Message that is actually sent, so if any Messages are currently Queued up to be sent, they will be sent using the new encoding. Note that to use any of the MUSCLE_MESSAGE_ENCODING_ZLIB_* encodings, you MUST have defined the compiler symbol -DMUSCLE_ENABLE_ZLIB_ENCODING.

Parameters:
ec Encoding type to use. Should be one of the MUSCLE_MESSAGE_ENCODING_* constants.

Definition at line 122 of file MessageIOGateway.h.

virtual status_t MessageIOGateway::ExecuteSynchronousMessaging ( AbstractGatewayMessageReceiver optReceiver,
uint64  timeoutPeriod = MUSCLE_TIME_NEVER 
) [virtual]

Overwritten to augment AbstractMessageIOGateway::ExecuteSynchronousMessaging() with some additional logic that prepends a PR_COMMAND_PING to the outgoing Message queue and then makes sure that ExecuteSynchronousMessaging() doesn't return until the corresponding PR_COMMAND_PONG is received.

That way we are guaranteed that the server's results are returned before this method returns.

Parameters:
optReceiver optional object to call MessageReceivedFromGateway() on when a reply Message is received.
timeoutPeriod Optional timeout period in microseconds, or MUSCLE_TIME_NEVER if no timeout is requested.
Returns:
B_NO_ERROR on success, or B_ERROR on failure (timeout or network error)

Reimplemented from AbstractMessageIOGateway.

virtual int32 MessageIOGateway::DoOutputImplementation ( uint32  maxBytes = MUSCLE_NO_LIMIT  )  [protected, virtual]

Writes some of our outgoing message bytes to the wire.

Not guaranteed to write all outgoing messages (it will try not to block)

Parameters:
maxBytes optional limit on the number of bytes that should be sent out. Defaults to MUSCLE_NO_LIMIT (which is a very large number)
Returns:
The number of bytes written, or a negative value if the connection has been broken or some other catastrophic condition has occurred.

Implements AbstractMessageIOGateway.

virtual int32 MessageIOGateway::DoInputImplementation ( AbstractGatewayMessageReceiver receiver,
uint32  maxBytes = MUSCLE_NO_LIMIT 
) [protected, virtual]

Reads some more incoming message bytes from the wire.

Any time a new Message is received, MessageReceivedFromGateway() should be called on the provided AbstractGatewayMessageReceiver to notify him about it.

Parameters:
receiver An object to call MessageReceivedFromGateway() on whenever a new incoming Message is available.
maxBytes optional limit on the number of bytes that should be read in. Defaults to MUSCLE_NO_LIMIT (which is a very large number) Tries not to block, but may (if the held DataIO object is in blocking mode)
Returns:
The number of bytes read, or a negative value if the connection has been broken or some other catastrophic condition has occurred.

Implements AbstractMessageIOGateway.

virtual ByteBufferRef MessageIOGateway::FlattenMessage ( const MessageRef msgRef,
uint8 *  header 
) const [protected, virtual]

Flattens a specified Message object into a flat ByteBuffer object.

Parameters:
msgRef Reference to a Message to flatten into a byte array.
header Pointer to a buffer that is (GetHeaderSize()) bytes long. The appropriate header bytes should be written in to this buffer.
Returns:
A reference to a ByteBuffer object containing the flattened Message data on success, or a NULL reference on failure. The default implementation uses msg.Flatten() and then (optionally) ZLib compression to produce the bytes.

virtual MessageRef MessageIOGateway::UnflattenMessage ( const ByteBufferRef bufRef,
const uint8 *  header 
) const [protected, virtual]

Unflattens a specified ByteBuffer object back into a MessageRef object.

Parameters:
bufRef Reference to a ByteBuffer object to unflatten back into a Message.
header Points to the header bytes that were received for this Message. This array is (GetHeaderSize()) bytes long.
Returns:
a Reference to a Message object containing the Message that was encoded in the ByteBuffer on success, or a NULL reference on failure. The default implementation uses (optional) ZLib decompression (depending on the header bytes) and then msg.Unflatten() to produce the Message.

virtual uint32 MessageIOGateway::GetHeaderSize (  )  const [protected, virtual]

Returns the size of the pre-flattened-message header section, in bytes.

The default Message protocol uses an 8-byte header (4 bytes for encoding ID, 4 bytes for message size), so the default implementation of this method always returns 8.

virtual int32 MessageIOGateway::GetBodySize ( const uint8 *  header  )  const [protected, virtual]

Must Extract and returns the buffer body size from the given header.

Note that the returned size should NOT count the header bytes themselves!

Parameters:
header Points to the header of the message. The header is GetHeaderSize() bytes long.
Returns:
The number of bytes in the body of the message associated with (header), on success, or a negative value to indicate an error (invalid header, etc).

status_t AbstractMessageIOGateway::AddOutgoingMessage ( const MessageRef messageRef  )  [inline, inherited]

Appends the given message reference to the end of our list of outgoing messages to send.

Never blocks.

Parameters:
messageRef A reference to the Message to send out through the gateway.
Returns:
B_NO_ERROR on success, B_ERROR iff for some reason the message can't be queued (out of memory?)

Definition at line 120 of file AbstractMessageIOGateway.h.

int32 AbstractMessageIOGateway::DoOutput ( uint32  maxBytes = MUSCLE_NO_LIMIT  )  [inline, inherited]

Writes some of our outgoing message bytes to the wire.

Not guaranteed to write all outgoing messages (it will try not to block)

Note:
Do not override this method! Override DoOutputImplementation() instead!
Parameters:
maxBytes optional limit on the number of bytes that should be sent out. Defaults to MUSCLE_NO_LIMIT (which is a very large number)
Returns:
The number of bytes written, or a negative value if the connection has been broken or some other catastrophic condition has occurred.

Definition at line 131 of file AbstractMessageIOGateway.h.

References AbstractMessageIOGateway::DoOutputImplementation().

int32 AbstractMessageIOGateway::DoInput ( AbstractGatewayMessageReceiver receiver,
uint32  maxBytes = MUSCLE_NO_LIMIT 
) [inline, inherited]

Reads some more incoming message bytes from the wire.

Any time a new Message is received, MessageReceivedFromGateway() should be called on the provided AbstractGatewayMessageReceiver to notify him about it.

Note:
Do not override this method! Override DoInputImplementation() instead!
Parameters:
receiver An object to call MessageReceivedFromGateway() on whenever a new incoming Message is available.
maxBytes optional limit on the number of bytes that should be read in. Defaults to MUSCLE_NO_LIMIT (which is a very large number) Tries not to block, but may (depending on implementation)
Returns:
The number of bytes read, or a negative value if the connection has been broken or some other catastrophic condition has occurred.

Definition at line 146 of file AbstractMessageIOGateway.h.

References AbstractGatewayMessageReceiver::DoInputBegins(), AbstractGatewayMessageReceiver::DoInputEnds(), and AbstractMessageIOGateway::DoInputImplementation().

virtual bool AbstractMessageIOGateway::IsReadyForInput (  )  const [virtual, inherited]

Should return true if this gateway is willing to receive from bytes from the wire.

Should return false if (for some reason) the gateway doesn't want to read any bytes right now. The default implementation of this method always returns true.

virtual uint64 AbstractMessageIOGateway::GetOutputStallLimit (  )  const [virtual, inherited]

Returns the number of microseconds that output to this gateway's client should be allowed to stall for.

If the output stalls for longer than this amount of time, the connection will be closed. Return MUSCLE_TIME_NEVER to disable stall limit checking. Default behaviour is to forward this call to the held DataIO object.

virtual void AbstractMessageIOGateway::Shutdown (  )  [virtual, inherited]

Shuts down the gateway.

Default implementation calls Shutdown() on the held DataIO object.

void AbstractMessageIOGateway::SetFlushOnEmpty ( bool  flush  )  [inherited]

By default, the AbstractMessageIOGateway calls Flush() on its DataIO's output stream whenever the last outgoing message in the outgoing message queue is sent.

Call SetFlushOnEmpty(false) to inhibit this behavior (e.g. for bandwidth efficiency when low message latency is not a requirement).

Parameters:
flush If true, auto-flushing will be enabled. If false, it will be disabled.

void AbstractMessageIOGateway::SetDataIO ( const DataIORef ref  )  [inline, inherited]

Installs (ref) as the DataIO object we will use for our I/O.

Typically called by the ReflectServer object.

Definition at line 212 of file AbstractMessageIOGateway.h.

status_t AbstractMessageIOGateway::EnsureBufferSize ( uint8 **  bufPtr,
uint32 *  bufSize,
uint32  desiredSize,
uint32  copySize 
) [protected, inherited]

Convenience method to allocate or reallocate a buffer.

When this method returns successfully, (*bufPtr) will point to a buffer that is at least (desiredSize) bytes long.

Parameters:
bufPtr points to a pointer to the buffer. (May point to a NULL pointer if no buffer is currently allocated)
bufSize points to the current size of the buffer. On return, this value is changed to reflect the new buffer size.
desiredSize indicates the minimum new buffer size required.
copySize indicates the number of bytes to copy out of the old buffer and into the new one, if a reallocation is necessary.
Returns:
B_NO_ERROR on success, B_ERROR on failure (i.e. out of memory).

void AbstractMessageIOGateway::FreeLargeBuffer ( uint8 **  bufPtr,
uint32 *  bufSize 
) [protected, inherited]

Convenience method; frees the given buffer and resets it to NULL, if the buffer is greater than 10 kilobytes big.

(Buffers smaller than that are not effected, since it's probably cheaper to keep them around and avoid having to deallocate and reallocate them all the time).

Parameters:
bufPtr points to a pointer to the buffer. (May point to a NULL pointer if no buffer is currently allocated). The pointer may be set to NULL if the buffer was freed.
bufSize points to the size-value of the buffer. May be set to 0 if the buffer was freed.

virtual void AbstractMessageIOGateway::SynchronousAfterMessageReceivedFromGateway ( const MessageRef msg,
void *  userData,
AbstractGatewayMessageReceiver r 
) [inline, protected, virtual, inherited]

Called by ExecuteSynchronousMessaging() after a Message is received.

Default implementation just passes the call on to the like-named method in (r)

Definition at line 307 of file AbstractMessageIOGateway.h.

References AbstractGatewayMessageReceiver::AfterMessageReceivedFromGateway().

virtual void AbstractMessageIOGateway::SynchronousBeginMessageReceivedFromGatewayBatch ( AbstractGatewayMessageReceiver r  )  [inline, protected, virtual, inherited]

Called by ExecuteSynchronousMessaging() when a batch of Messages is about to be received.

Default implementation just passes the call on to the like-named method in (r)

Definition at line 310 of file AbstractMessageIOGateway.h.

References AbstractGatewayMessageReceiver::BeginMessageReceivedFromGatewayBatch().

virtual void AbstractMessageIOGateway::SynchronousEndMessageReceivedFromGatewayBatch ( AbstractGatewayMessageReceiver r  )  [inline, protected, virtual, inherited]

Called by ExecuteSynchronousMessaging() when all Messages in a batch have been received.

Default implementation just passes the call on to the like-named method in (r)

Definition at line 313 of file AbstractMessageIOGateway.h.

References AbstractGatewayMessageReceiver::EndMessageReceivedFromGatewayBatch().

void RefCountable::IncrementRefCount (  )  const [inline, inherited]

Increments the counter and returns true iff the new value is zero.

Thread safe.

Definition at line 32 of file RefCount.h.

References AtomicCounter::AtomicIncrement().

bool RefCountable::DecrementRefCount (  )  const [inline, inherited]

Decrements the counter and returns true iff the new value is zero.

Thread safe.

Definition at line 35 of file RefCount.h.

References AtomicCounter::AtomicDecrement().

void RefCountable::SetManager ( AbstractObjectManager manager  )  [inline, inherited]

Sets the recycle-pointer for this object.

If set to non-NULL, this pointer is used by the ObjectPool class to recycle this object when it is no longer in use, so as to avoid the overhead of having to delete it and re-create it later on. The RefCountable class itself does nothing with this pointer. Default value is NULL.

Parameters:
manager Pointer to the new manager object to use, or NULL to use no manager.

Definition at line 44 of file RefCount.h.

uint32 RefCountable::GetRefCount (  )  const [inline, inherited]

Returns this object's current reference count.

Note that the value returned by this method is volatile in multithreaded environments, so it may already be wrong by the time it is returned. Be careful!

Definition at line 54 of file RefCount.h.

References AtomicCounter::GetCount().

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

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, inherited]

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  )  [inherited]

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  )  [inherited]

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, inherited]

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 PulseNode::_parent.

uint64 PulseNode::GetCycleStartTime (  )  const [inline, inherited]

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, inherited]

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, inherited]

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, inherited]

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, inherited]

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:12 2008 for MUSCLE by  doxygen 1.5.1