From 65c5efe43b68700bad94076d4cd421160203c5de Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Fri, 16 May 2008 01:22:11 +0000 Subject: Formatting cleanup. --- .../Communications/Limit/IRequestLimitStrategy.cs | 10 ++--- .../Communications/Limit/NullLimitStrategy.cs | 6 +-- .../Communications/Limit/RepeatLimitStrategy.cs | 38 ++++++++-------- .../Communications/Limit/TimeLimitStrategy.cs | 50 +++++++++++----------- 4 files changed, 52 insertions(+), 52 deletions(-) (limited to 'OpenSim/Framework/Communications/Limit') diff --git a/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs index 6ec21d9..1a9cc24 100644 --- a/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs +++ b/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs @@ -31,9 +31,9 @@ namespace OpenSim.Framework.Communications.Limit /// Interface for strategies that can limit requests from the client. Currently only used in the /// texture modules to deal with repeated requests for certain textures. However, limiting strategies /// could be used with other requests. - /// + /// public interface IRequestLimitStrategy - { + { /// /// Should the request be allowed? If the id is not monitored, then the request is always allowed. /// Otherwise, the strategy criteria will be applied. @@ -41,21 +41,21 @@ namespace OpenSim.Framework.Communications.Limit /// /// bool AllowRequest(TId id); - + /// /// Has the request been refused just once? /// /// False if the request has not yet been refused, or if the request has been refused more /// than once. bool IsFirstRefusal(TId id); - + /// /// Start monitoring for future AllowRequest calls. If the id is already monitored, then monitoring /// continues. /// /// void MonitorRequests(TId id); - + /// /// Is the id being monitored? /// diff --git a/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs index 72d0586..932f780 100644 --- a/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs +++ b/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs @@ -26,15 +26,15 @@ */ namespace OpenSim.Framework.Communications.Limit -{ +{ /// /// Strategy which polices no limits /// public class NullLimitStrategy : IRequestLimitStrategy - { + { public bool AllowRequest(TId id) { return true; } public bool IsFirstRefusal(TId id) { return false; } public void MonitorRequests(TId id) { /* intentionally blank */ } - public bool IsMonitoringRequests(TId id) { return false; } + public bool IsMonitoringRequests(TId id) { return false; } } } diff --git a/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs index dfa05fa..bb72029 100644 --- a/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs +++ b/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs @@ -31,14 +31,14 @@ namespace OpenSim.Framework.Communications.Limit { /// /// Limit requests by discarding them after they've been repeated a certain number of times. - /// + /// public class RepeatLimitStrategy : IRequestLimitStrategy { /// /// Record each asset request that we're notified about. /// private readonly Dictionary requestCounts = new Dictionary(); - + /// /// The maximum number of requests that can be made before we drop subsequent requests. /// @@ -47,7 +47,7 @@ namespace OpenSim.Framework.Communications.Limit { get { return m_maxRequests; } } - + /// /// The maximum number of requests that may be served before all further /// requests are dropped. @@ -55,52 +55,52 @@ namespace OpenSim.Framework.Communications.Limit { m_maxRequests = maxRequests; } - + /// /// /// public bool AllowRequest(TId id) - { + { if (requestCounts.ContainsKey(id)) { requestCounts[id] += 1; - + if (requestCounts[id] > m_maxRequests) - { + { return false; - } + } } - + return true; } - + /// /// - /// + /// public bool IsFirstRefusal(TId id) { if (requestCounts.ContainsKey(id) && m_maxRequests + 1 == requestCounts[id]) { return true; - } - + } + return false; } - + /// /// - /// + /// public void MonitorRequests(TId id) { if (!IsMonitoringRequests(id)) { requestCounts.Add(id, 1); - } - } - + } + } + /// /// - /// + /// public bool IsMonitoringRequests(TId id) { return requestCounts.ContainsKey(id); 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 { /// /// Limit requests by discarding repeat attempts that occur within a given time period - /// + /// /// XXX Don't use this for limiting texture downloading, at least not until we better handle multiple requests /// for the same texture at different resolutions. - /// + /// public class TimeLimitStrategy : IRequestLimitStrategy { /// /// Record the time at which an asset request occurs. /// - private readonly Dictionary requests = new Dictionary(); - + private readonly Dictionary requests = new Dictionary(); + /// /// The minimum time period between which requests for the same data will be serviced. /// @@ -53,37 +53,37 @@ namespace OpenSim.Framework.Communications.Limit } /// - /// + /// public TimeLimitStrategy(TimeSpan repeatPeriod) { m_repeatPeriod = repeatPeriod; } - + /// /// /// public bool AllowRequest(TId id) - { + { if (IsMonitoringRequests(id)) { DateTime now = DateTime.Now; TimeSpan elapsed = now - requests[id].Time; - + if (elapsed < RepeatPeriod) { requests[id].Refusals += 1; return false; } - - requests[id].Time = now; + + requests[id].Time = now; } - + return true; } - + /// /// - /// + /// public bool IsFirstRefusal(TId id) { if (IsMonitoringRequests(id)) @@ -92,31 +92,31 @@ namespace OpenSim.Framework.Communications.Limit { return true; } - } - + } + return false; } - + /// /// - /// + /// public void MonitorRequests(TId id) { if (!IsMonitoringRequests(id)) { requests.Add(id, new Request(DateTime.Now)); - } - } - + } + } + /// /// - /// + /// public bool IsMonitoringRequests(TId id) { return requests.ContainsKey(id); - } + } } - + /// /// Private request details. /// @@ -126,12 +126,12 @@ namespace OpenSim.Framework.Communications.Limit /// Time of last request /// public DateTime Time; - + /// /// Number of refusals associated with this request /// public int Refusals; - + public Request(DateTime time) { Time = time; -- cgit v1.1