aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs
diff options
context:
space:
mode:
authorJeff Ames2008-05-16 01:22:11 +0000
committerJeff Ames2008-05-16 01:22:11 +0000
commit65c5efe43b68700bad94076d4cd421160203c5de (patch)
tree589b56649ed02f4942671fd6e51c6dc43f682e0d /OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs
parentThank you very much, mjm for : (diff)
downloadopensim-SC_OLD-65c5efe43b68700bad94076d4cd421160203c5de.zip
opensim-SC_OLD-65c5efe43b68700bad94076d4cd421160203c5de.tar.gz
opensim-SC_OLD-65c5efe43b68700bad94076d4cd421160203c5de.tar.bz2
opensim-SC_OLD-65c5efe43b68700bad94076d4cd421160203c5de.tar.xz
Formatting cleanup.
Diffstat (limited to 'OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs')
-rw-r--r--OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs50
1 files changed, 25 insertions, 25 deletions
diff --git a/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs
index 34b01ff..b5b925e 100644
--- a/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs
+++ b/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs
@@ -32,17 +32,17 @@ namespace OpenSim.Framework.Communications.Limit
32{ 32{
33 /// <summary> 33 /// <summary>
34 /// Limit requests by discarding repeat attempts that occur within a given time period 34 /// Limit requests by discarding repeat attempts that occur within a given time period
35 /// 35 ///
36 /// XXX Don't use this for limiting texture downloading, at least not until we better handle multiple requests 36 /// XXX Don't use this for limiting texture downloading, at least not until we better handle multiple requests
37 /// for the same texture at different resolutions. 37 /// for the same texture at different resolutions.
38 /// </summary> 38 /// </summary>
39 public class TimeLimitStrategy<TId> : IRequestLimitStrategy<TId> 39 public class TimeLimitStrategy<TId> : IRequestLimitStrategy<TId>
40 { 40 {
41 /// <summary> 41 /// <summary>
42 /// Record the time at which an asset request occurs. 42 /// Record the time at which an asset request occurs.
43 /// </summary> 43 /// </summary>
44 private readonly Dictionary<TId, Request> requests = new Dictionary<TId, Request>(); 44 private readonly Dictionary<TId, Request> requests = new Dictionary<TId, Request>();
45 45
46 /// <summary> 46 /// <summary>
47 /// The minimum time period between which requests for the same data will be serviced. 47 /// The minimum time period between which requests for the same data will be serviced.
48 /// </summary> 48 /// </summary>
@@ -53,37 +53,37 @@ namespace OpenSim.Framework.Communications.Limit
53 } 53 }
54 54
55 /// <summary></summary> 55 /// <summary></summary>
56 /// <param name="repeatPeriod"></param> 56 /// <param name="repeatPeriod"></param>
57 public TimeLimitStrategy(TimeSpan repeatPeriod) 57 public TimeLimitStrategy(TimeSpan repeatPeriod)
58 { 58 {
59 m_repeatPeriod = repeatPeriod; 59 m_repeatPeriod = repeatPeriod;
60 } 60 }
61 61
62 /// <summary> 62 /// <summary>
63 /// <see cref="IRequestLimitStrategy"/> 63 /// <see cref="IRequestLimitStrategy"/>
64 /// </summary> 64 /// </summary>
65 public bool AllowRequest(TId id) 65 public bool AllowRequest(TId id)
66 { 66 {
67 if (IsMonitoringRequests(id)) 67 if (IsMonitoringRequests(id))
68 { 68 {
69 DateTime now = DateTime.Now; 69 DateTime now = DateTime.Now;
70 TimeSpan elapsed = now - requests[id].Time; 70 TimeSpan elapsed = now - requests[id].Time;
71 71
72 if (elapsed < RepeatPeriod) 72 if (elapsed < RepeatPeriod)
73 { 73 {
74 requests[id].Refusals += 1; 74 requests[id].Refusals += 1;
75 return false; 75 return false;
76 } 76 }
77 77
78 requests[id].Time = now; 78 requests[id].Time = now;
79 } 79 }
80 80
81 return true; 81 return true;
82 } 82 }
83 83
84 /// <summary> 84 /// <summary>
85 /// <see cref="IRequestLimitStrategy"/> 85 /// <see cref="IRequestLimitStrategy"/>
86 /// </summary> 86 /// </summary>
87 public bool IsFirstRefusal(TId id) 87 public bool IsFirstRefusal(TId id)
88 { 88 {
89 if (IsMonitoringRequests(id)) 89 if (IsMonitoringRequests(id))
@@ -92,31 +92,31 @@ namespace OpenSim.Framework.Communications.Limit
92 { 92 {
93 return true; 93 return true;
94 } 94 }
95 } 95 }
96 96
97 return false; 97 return false;
98 } 98 }
99 99
100 /// <summary> 100 /// <summary>
101 /// <see cref="IRequestLimitStrategy"/> 101 /// <see cref="IRequestLimitStrategy"/>
102 /// </summary> 102 /// </summary>
103 public void MonitorRequests(TId id) 103 public void MonitorRequests(TId id)
104 { 104 {
105 if (!IsMonitoringRequests(id)) 105 if (!IsMonitoringRequests(id))
106 { 106 {
107 requests.Add(id, new Request(DateTime.Now)); 107 requests.Add(id, new Request(DateTime.Now));
108 } 108 }
109 } 109 }
110 110
111 /// <summary> 111 /// <summary>
112 /// <see cref="IRequestLimitStrategy"/> 112 /// <see cref="IRequestLimitStrategy"/>
113 /// </summary> 113 /// </summary>
114 public bool IsMonitoringRequests(TId id) 114 public bool IsMonitoringRequests(TId id)
115 { 115 {
116 return requests.ContainsKey(id); 116 return requests.ContainsKey(id);
117 } 117 }
118 } 118 }
119 119
120 /// <summary> 120 /// <summary>
121 /// Private request details. 121 /// Private request details.
122 /// </summary> 122 /// </summary>
@@ -126,12 +126,12 @@ namespace OpenSim.Framework.Communications.Limit
126 /// Time of last request 126 /// Time of last request
127 /// </summary> 127 /// </summary>
128 public DateTime Time; 128 public DateTime Time;
129 129
130 /// <summary> 130 /// <summary>
131 /// Number of refusals associated with this request 131 /// Number of refusals associated with this request
132 /// </summary> 132 /// </summary>
133 public int Refusals; 133 public int Refusals;
134 134
135 public Request(DateTime time) 135 public Request(DateTime time)
136 { 136 {
137 Time = time; 137 Time = time;