Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

cabal_channel.h

00001 /*
00002    cabal_channel.h
00003    
00004    CABAL - CAched BAlanced Lan
00005    Channel (socket collection) class.
00006 
00007    $Id: cabal_channel.h,v 1.4 2004/04/10 15:28:16 jonnymind Exp $
00008 ---------------------------------------------
00009    Begin      : 2003-12-27 06:15
00010    Author     : Giancarlo Niccolai
00011 
00012    Last modified because:
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    // copy constructor NOT allowed
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 /* End of cabal_channel.h */

Generated on Sat Apr 10 17:41:48 2004 for Cabal by doxygen 1.3.5