Main Page   Modules   Namespace List   Class Hierarchy   Compound List   Namespace Members   Compound Members   Related Pages  

GNE::PacketFeeder Class Reference
[Mid-Level API]

#include <PacketFeeder.h>

List of all members.

Public Types

typedef SmartPtr< PacketFeeder > sptr
typedef WeakPtr< PacketFeeder > wptr

Public Member Functions

virtual void onLowPackets (PacketStream &ps)=0
 The specified PacketStream is running low on packets, and you are given the opportunity at this time to add more packets to its outgoing queue.


Detailed Description

The PacketFeeder class is a callback for the PacketStream thread when it is running low on packets. How low before the callback occurs is defined by a parameter set in the PacketStream class during connection creation or through PacketStream::setLowPacketThreshold. This class replaces the old onDoneWriting event in ConnectionListener, because this method allows for the writing to be stalled during this callback and also allows for the callback to occur before all packets run out.

This is a good thing. It cuts out the extra latency from passing the event to the EventThread and getting the packets back, and in addition allows the PacketStream to never run out of data and therefore take advantage of optimizing the packet stream through packet combining. Since the callback takes place in the writing thread itself, it cannot be writing therefore you can send out a batch of packets with a better assurance they will be combined and optimized.


Member Function Documentation

virtual void GNE::PacketFeeder::onLowPackets PacketStream ps  )  [pure virtual]
 

The specified PacketStream is running low on packets, and you are given the opportunity at this time to add more packets to its outgoing queue.

The callback will be called at least once when the PacketStream gets sufficently low. If you do not add enough packets it may be called (actually very likely) multiple times. If the PacketStream actually runs out of packets the writer thread will wait and will attempt to reprocess the event after the suggested timeout set by PacketStream::setFeederTimeout.

You can use the informational methods of ps to get information about how many packets are left and such to better optimize your sending.


The documentation for this class was generated from the following file:
Generated on Fri Aug 22 13:40:06 2003 for GNE by doxygen1.3