llthrottle.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLTHROTTLE_H
00033 #define LL_LLTHROTTLE_H
00034 
00035 #include "lltimer.h"
00036 
00037 const S32 MAX_THROTTLE_SIZE = 32;
00038 
00039 class LLDataPacker;
00040 
00041 // Single instance of a generic throttle
00042 class LLThrottle
00043 {
00044 public:
00045         LLThrottle(const F32 throttle = 1.f);
00046         ~LLThrottle() { }
00047 
00048         void setRate(const F32 rate);
00049         BOOL checkOverflow(const F32 amount); // I'm about to add an amount, TRUE if would overflow throttle
00050         BOOL throttleOverflow(const F32 amount); // I just sent amount, TRUE if that overflowed the throttle
00051 
00052         F32 getAvailable();     // Return the available bits
00053         F32 getRate() const                             { return mRate; }
00054 private:
00055         F32 mLookaheadSecs;     // Seconds to look ahead, maximum
00056         F32     mRate;  // BPS available, dynamically adjusted
00057         F32     mAvailable;     // Bits available to send right now on each channel
00058         F64     mLastSendTime;          // Time since last send on this channel
00059 };
00060 
00061 typedef enum e_throttle_categories
00062 {
00063         TC_RESEND,
00064         TC_LAND,
00065         TC_WIND,
00066         TC_CLOUD,
00067         TC_TASK,
00068         TC_TEXTURE,
00069         TC_ASSET,
00070         TC_EOF
00071 } EThrottleCats;
00072 
00073 
00074 class LLThrottleGroup
00075 {
00076 public:
00077         LLThrottleGroup();
00078         ~LLThrottleGroup() { }
00079 
00080         void    resetDynamicAdjust();
00081         BOOL    checkOverflow(S32 throttle_cat, F32 bits);              // I'm about to send bits, TRUE if would overflow channel
00082         BOOL    throttleOverflow(S32 throttle_cat, F32 bits);   // I just sent bits, TRUE if that overflowed the channel
00083         BOOL    dynamicAdjust();                // Shift bandwidth from idle channels to busy channels, TRUE if adjustment occurred
00084         BOOL    setNominalBPS(F32* throttle_vec);                               // TRUE if any value was different, resets adjustment system if was different
00085 
00086         void packThrottle(LLDataPacker &dp) const;
00087         void unpackThrottle(LLDataPacker &dp);
00088 public:
00089         F32             mThrottleTotal[TC_EOF]; // BPS available, sent by viewer, sum for all simulators
00090 
00091 protected:
00092         F32             mNominalBPS[TC_EOF];    // BPS available, adjusted to be just this simulator
00093         F32             mCurrentBPS[TC_EOF];    // BPS available, dynamically adjusted
00094 
00095         F32             mBitsAvailable[TC_EOF]; // Bits available to send right now on each channel
00096         F32             mBitsSentThisPeriod[TC_EOF];    // Sent in this dynamic allocation period
00097         F32             mBitsSentHistory[TC_EOF];               // Sent before this dynamic allocation period, adjusted to one period length
00098 
00099         F64             mLastSendTime[TC_EOF];          // Time since last send on this channel
00100         F64             mDynamicAdjustTime;     // Only dynamic adjust every 2 seconds or so.
00101 
00102 };
00103 
00104 #endif

Generated on Thu Jul 1 06:09:19 2010 for Second Life Viewer by  doxygen 1.4.7