aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2014-10-10 18:38:54 +0100
committerJustin Clark-Casey (justincc)2014-11-25 23:21:37 +0000
commitead32de790006313c2070c07c6f4fefd58acb6e6 (patch)
treed3620128412019c017963e6e1ac26c1e41af9873 /OpenSim/Region
parentRemove the unnecessary intermediate total token bucket. (diff)
downloadopensim-SC-ead32de790006313c2070c07c6f4fefd58acb6e6.zip
opensim-SC-ead32de790006313c2070c07c6f4fefd58acb6e6.tar.gz
opensim-SC-ead32de790006313c2070c07c6f4fefd58acb6e6.tar.bz2
opensim-SC-ead32de790006313c2070c07c6f4fefd58acb6e6.tar.xz
Use automatic properties for Parent and TotalDripRequest in TokenBucket to make code analysis easier. No functional change.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs53
1 files changed, 21 insertions, 32 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs b/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs
index fbc40a6..d696265 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs
@@ -84,12 +84,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
84 /// parent. The parent bucket will limit the aggregate bandwidth of all 84 /// parent. The parent bucket will limit the aggregate bandwidth of all
85 /// of its children buckets 85 /// of its children buckets
86 /// </summary> 86 /// </summary>
87 protected TokenBucket m_parent; 87 public TokenBucket Parent { get; protected set; }
88 public TokenBucket Parent
89 {
90 get { return m_parent; }
91 set { m_parent = value; }
92 }
93 88
94 /// <summary> 89 /// <summary>
95 /// Maximum burst rate in bytes per second. This is the maximum number 90 /// Maximum burst rate in bytes per second. This is the maximum number
@@ -124,23 +119,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP
124 protected Int64 m_dripRate; 119 protected Int64 m_dripRate;
125 public virtual Int64 RequestedDripRate 120 public virtual Int64 RequestedDripRate
126 { 121 {
127 get { return (m_dripRate == 0 ? m_totalDripRequest : m_dripRate); } 122 get { return (m_dripRate == 0 ? TotalDripRequest : m_dripRate); }
128 set { 123 set {
129 m_dripRate = (value < 0 ? 0 : value); 124 m_dripRate = (value < 0 ? 0 : value);
130 m_burstRate = (Int64)((double)m_dripRate * m_quantumsPerBurst); 125 m_burstRate = (Int64)((double)m_dripRate * m_quantumsPerBurst);
131 m_totalDripRequest = m_dripRate; 126 TotalDripRequest = m_dripRate;
132 if (m_parent != null) 127 if (Parent != null)
133 m_parent.RegisterRequest(this,m_dripRate); 128 Parent.RegisterRequest(this,m_dripRate);
134 } 129 }
135 } 130 }
136 131
137 public virtual Int64 DripRate 132 public virtual Int64 DripRate
138 { 133 {
139 get { 134 get {
140 if (m_parent == null) 135 if (Parent == null)
141 return Math.Min(RequestedDripRate,TotalDripRequest); 136 return Math.Min(RequestedDripRate, TotalDripRequest);
142 137
143 double rate = (double)RequestedDripRate * m_parent.DripRateModifier(); 138 double rate = (double)RequestedDripRate * Parent.DripRateModifier();
144 if (rate < m_minimumDripRate) 139 if (rate < m_minimumDripRate)
145 rate = m_minimumDripRate; 140 rate = m_minimumDripRate;
146 141
@@ -152,12 +147,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
152 /// The current total of the requested maximum burst rates of 147 /// The current total of the requested maximum burst rates of
153 /// this bucket's children buckets. 148 /// this bucket's children buckets.
154 /// </summary> 149 /// </summary>
155 protected Int64 m_totalDripRequest; 150 public Int64 TotalDripRequest { get; protected set; }
156 public Int64 TotalDripRequest
157 {
158 get { return m_totalDripRequest; }
159 set { m_totalDripRequest = value; }
160 }
161 151
162#endregion Properties 152#endregion Properties
163 153
@@ -216,16 +206,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
216 lock (m_children) 206 lock (m_children)
217 { 207 {
218 m_children[child] = request; 208 m_children[child] = request;
219 // m_totalDripRequest = m_children.Values.Sum(); 209 // TotalDripRequest = m_children.Values.Sum();
220 210
221 m_totalDripRequest = 0; 211 TotalDripRequest = 0;
222 foreach (KeyValuePair<TokenBucket, Int64> cref in m_children) 212 foreach (KeyValuePair<TokenBucket, Int64> cref in m_children)
223 m_totalDripRequest += cref.Value; 213 TotalDripRequest += cref.Value;
224 } 214 }
225 215
226 // Pass the new values up to the parent 216 // Pass the new values up to the parent
227 if (m_parent != null) 217 if (Parent != null)
228 m_parent.RegisterRequest(this,Math.Min(RequestedDripRate, TotalDripRequest)); 218 Parent.RegisterRequest(this,Math.Min(RequestedDripRate, TotalDripRequest));
229 } 219 }
230 220
231 /// <summary> 221 /// <summary>
@@ -239,15 +229,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
239 m_children.Remove(child); 229 m_children.Remove(child);
240 // m_totalDripRequest = m_children.Values.Sum(); 230 // m_totalDripRequest = m_children.Values.Sum();
241 231
242 m_totalDripRequest = 0; 232 TotalDripRequest = 0;
243 foreach (KeyValuePair<TokenBucket, Int64> cref in m_children) 233 foreach (KeyValuePair<TokenBucket, Int64> cref in m_children)
244 m_totalDripRequest += cref.Value; 234 TotalDripRequest += cref.Value;
245 } 235 }
246
247 236
248 // Pass the new values up to the parent 237 // Pass the new values up to the parent
249 if (m_parent != null) 238 if (Parent != null)
250 m_parent.RegisterRequest(this,Math.Min(RequestedDripRate, TotalDripRequest)); 239 Parent.RegisterRequest(this,Math.Min(RequestedDripRate, TotalDripRequest));
251 } 240 }
252 241
253 /// <summary> 242 /// <summary>
@@ -336,7 +325,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
336 protected Int64 m_maxDripRate = 0; 325 protected Int64 m_maxDripRate = 0;
337 public Int64 MaxDripRate 326 public Int64 MaxDripRate
338 { 327 {
339 get { return (m_maxDripRate == 0 ? m_totalDripRequest : m_maxDripRate); } 328 get { return (m_maxDripRate == 0 ? TotalDripRequest : m_maxDripRate); }
340 set { m_maxDripRate = (value == 0 ? 0 : Math.Max(value,m_minimumFlow)); } 329 set { m_maxDripRate = (value == 0 ? 0 : Math.Max(value,m_minimumFlow)); }
341 } 330 }
342 331
@@ -351,8 +340,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
351 set { 340 set {
352 m_dripRate = OpenSim.Framework.Util.Clamp<Int64>(value,m_minimumFlow,MaxDripRate); 341 m_dripRate = OpenSim.Framework.Util.Clamp<Int64>(value,m_minimumFlow,MaxDripRate);
353 m_burstRate = (Int64)((double)m_dripRate * m_quantumsPerBurst); 342 m_burstRate = (Int64)((double)m_dripRate * m_quantumsPerBurst);
354 if (m_parent != null) 343 if (Parent != null)
355 m_parent.RegisterRequest(this, m_dripRate); 344 Parent.RegisterRequest(this, m_dripRate);
356 } 345 }
357 } 346 }
358 347