wasSharp – Diff between revs 2 and 5
?pathlinks?
Rev 2 | Rev 5 | |||
---|---|---|---|---|
Line 107... | Line 107... | |||
107 | /// Given a number of allowed events per seconds, this class allows you |
107 | /// Given a number of allowed events per seconds, this class allows you |
|
108 | /// to determine via the IsSafe property whether it is safe to trigger |
108 | /// to determine via the IsSafe property whether it is safe to trigger |
|
109 | /// another lined-up event. This is mostly used to check that throttles |
109 | /// another lined-up event. This is mostly used to check that throttles |
|
110 | /// are being respected. |
110 | /// are being respected. |
|
111 | /// </summary> |
111 | /// </summary> |
|
112 | public class wasTimedThrottle : IDisposable |
112 | public class TimedThrottle : IDisposable |
|
113 | { |
113 | { |
|
114 | private readonly uint EventsAllowed; |
114 | private readonly uint EventsAllowed; |
|
115 | private readonly object LockObject = new object(); |
115 | private readonly object LockObject = new object(); |
|
116 | private Timer timer; |
116 | private Timer timer; |
|
117 | private uint TriggeredEvents; |
117 | private uint TriggeredEvents; |
|
Line 118... | Line 118... | |||
118 | |
118 | |
|
119 | public wasTimedThrottle(uint events, uint seconds) |
119 | public TimedThrottle(uint events, uint seconds) |
|
120 | { |
120 | { |
|
121 | EventsAllowed = events; |
121 | EventsAllowed = events; |
|
122 | if (timer == null) |
122 | if (timer == null) |
|
123 | { |
123 | { |
|
Line 166... | Line 166... | |||
166 | /// of a decaying timer that tracks the time between rescheduling. |
166 | /// of a decaying timer that tracks the time between rescheduling. |
|
167 | /// </summary> |
167 | /// </summary> |
|
168 | /// <remarks> |
168 | /// <remarks> |
|
169 | /// (C) Wizardry and Steamworks 2013 - License: GNU GPLv3 |
169 | /// (C) Wizardry and Steamworks 2013 - License: GNU GPLv3 |
|
170 | /// </remarks> |
170 | /// </remarks> |
|
171 | public class wasAdaptiveAlarm : IDisposable |
171 | public class DecayingAlarm : IDisposable |
|
172 | { |
172 | { |
|
173 | [Flags] |
173 | [Flags] |
|
174 | public enum DECAY_TYPE |
174 | public enum DECAY_TYPE |
|
175 | { |
175 | { |
|
176 | [XmlEnum(Name = "none")] NONE = 0, |
176 | [XmlEnum(Name = "none")] NONE = 0, |
|
Line 187... | Line 187... | |||
187 | private Timer alarm; |
187 | private Timer alarm; |
|
Line 188... | Line 188... | |||
188 | |
188 | |
|
189 | /// <summary> |
189 | /// <summary> |
|
190 | /// The default constructor using no decay. |
190 | /// The default constructor using no decay. |
|
191 | /// </summary> |
191 | /// </summary> |
|
192 | public wasAdaptiveAlarm() |
192 | public DecayingAlarm() |
|
193 | { |
193 | { |
|
194 | Signal = new ManualResetEvent(false); |
194 | Signal = new ManualResetEvent(false); |
|
Line 195... | Line 195... | |||
195 | } |
195 | } |
|
196 | |
196 | |
|
197 | /// <summary> |
197 | /// <summary> |
|
198 | /// The constructor for the wasAdaptiveAlarm class taking as parameter a decay type. |
198 | /// The constructor for the DecayingAlarm class taking as parameter a decay type. |
|
199 | /// </summary> |
199 | /// </summary> |
|
200 | /// <param name="decay">the type of decay: arithmetic, geometric, harmonic, heronian or quadratic</param> |
200 | /// <param name="decay">the type of decay: arithmetic, geometric, harmonic, heronian or quadratic</param> |
|
201 | public wasAdaptiveAlarm(DECAY_TYPE decay) |
201 | public DecayingAlarm(DECAY_TYPE decay) |
|
202 | { |
202 | { |
|
203 | Signal = new ManualResetEvent(false); |
203 | Signal = new ManualResetEvent(false); |