aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/llthrottle.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llmessage/llthrottle.h
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llmessage/llthrottle.h')
-rw-r--r--linden/indra/llmessage/llthrottle.h100
1 files changed, 100 insertions, 0 deletions
diff --git a/linden/indra/llmessage/llthrottle.h b/linden/indra/llmessage/llthrottle.h
new file mode 100644
index 0000000..8fc2725
--- /dev/null
+++ b/linden/indra/llmessage/llthrottle.h
@@ -0,0 +1,100 @@
1/**
2 * @file llthrottle.h
3 * @brief LLThrottle class used for network bandwidth control
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#ifndef LL_LLTHROTTLE_H
29#define LL_LLTHROTTLE_H
30
31#include "lltimer.h"
32
33const S32 MAX_THROTTLE_SIZE = 32;
34
35class LLDataPacker;
36
37// Single instance of a generic throttle
38class LLThrottle
39{
40public:
41 LLThrottle(const F32 throttle = 1.f);
42 ~LLThrottle() { }
43
44 void setRate(const F32 rate);
45 BOOL checkOverflow(const F32 amount); // I'm about to add an amount, TRUE if would overflow throttle
46 BOOL throttleOverflow(const F32 amount); // I just sent amount, TRUE if that overflowed the throttle
47
48 F32 getAvailable(); // Return the available bits
49 F32 getRate() const { return mRate; }
50private:
51 F32 mLookaheadSecs; // Seconds to look ahead, maximum
52 F32 mRate; // BPS available, dynamically adjusted
53 F32 mAvailable; // Bits available to send right now on each channel
54 F64 mLastSendTime; // Time since last send on this channel
55};
56
57typedef enum e_throttle_categories
58{
59 TC_RESEND,
60 TC_LAND,
61 TC_WIND,
62 TC_CLOUD,
63 TC_TASK,
64 TC_TEXTURE,
65 TC_ASSET,
66 TC_EOF
67} EThrottleCats;
68
69
70class LLThrottleGroup
71{
72public:
73 LLThrottleGroup();
74 ~LLThrottleGroup() { }
75
76 void resetDynamicAdjust();
77 BOOL checkOverflow(S32 throttle_cat, F32 bits); // I'm about to send bits, TRUE if would overflow channel
78 BOOL throttleOverflow(S32 throttle_cat, F32 bits); // I just sent bits, TRUE if that overflowed the channel
79 BOOL dynamicAdjust(); // Shift bandwidth from idle channels to busy channels, TRUE if adjustment occurred
80 BOOL setNominalBPS(F32* throttle_vec); // TRUE if any value was different, resets adjustment system if was different
81
82 void packThrottle(LLDataPacker &dp) const;
83 void unpackThrottle(LLDataPacker &dp);
84public:
85 F32 mThrottleTotal[TC_EOF]; // BPS available, sent by viewer, sum for all simulators
86
87protected:
88 F32 mNominalBPS[TC_EOF]; // BPS available, adjusted to be just this simulator
89 F32 mCurrentBPS[TC_EOF]; // BPS available, dynamically adjusted
90
91 F32 mBitsAvailable[TC_EOF]; // Bits available to send right now on each channel
92 F32 mBitsSentThisPeriod[TC_EOF]; // Sent in this dynamic allocation period
93 F32 mBitsSentHistory[TC_EOF]; // Sent before this dynamic allocation period, adjusted to one period length
94
95 F64 mLastSendTime[TC_EOF]; // Time since last send on this channel
96 F64 mDynamicAdjustTime; // Only dynamic adjust every 2 seconds or so.
97
98};
99
100#endif