00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef CABAL_CHANNEL_H
00017 #define CABAL_CHANNEL_H
00018
00019 #include <list>
00020 #include <cabal_defs.h>
00021 #include <cabal_waiter.h>
00022
00023 namespace Cabal {
00024
00025 class Connection;
00026 class Socket;
00027
00029 typedef std::list< Connection *> ConList;
00031 typedef std::list< Socket *> SocketList;
00032
00033
00038 class Channel: public Waiter
00039 {
00040 private:
00041 long int m_bandwidth;
00043 long int m_lastSentTime;
00044 long int m_lastSentSize;
00045
00046 long int m_nextSchedule;
00047
00049 ConList m_cons[ CABAL_PRIORITIES ];
00050
00052 SocketList m_sockets;
00053
00055 void recptRoundRobin()
00056 {
00057 if ( ! m_sockets.empty() )
00058 {
00059 SocketList::iterator sit = m_sockets.begin();
00060 Socket *skt = (*sit);
00061 sit++;
00062 if ( sit != m_sockets.end() )
00063 {
00064 sit--;
00065 m_sockets.erase( sit );
00066 m_sockets.push_back( skt );
00067 }
00068 }
00069 }
00070
00071
00072
00073 public:
00074 Channel( const long bwidth=0 ) {
00075 m_bandwidth = bwidth;
00076 m_lastSentTime = -1001;
00077 m_lastSentSize = 0;
00078 m_nextSchedule = -1;
00079 }
00080
00081
00082
00084 void addSocket( Socket *skt );
00085
00087 void removeSocket( Socket *skt );
00088
00102 void schedule( Connection *con, const Priority prio );
00103
00114 void deschedule( const Connection *con, const Priority prio, const bool complete=false );
00115
00119 void deschedule( const Connection *con )
00120 {
00121 deschedule( con, realtime, true );
00122 deschedule( con, high_prio, true );
00123 deschedule( con, medium_prio, true );
00124 deschedule( con, low_prio, true );
00125 }
00126
00155 bool process( MSECS msecs );
00156
00157 };
00158
00159 }
00160
00161 #endif
00162
00163