public
Fork of mojombo/god
Description: Ruby process monitor
Homepage: http://god.rubyforge.org
Clone URL: git://github.com/Bertg/god.git
fix timer condition dedup behavior
mojombo (author)
Wed Jan 23 14:06:38 -0800 2008
commit  8ea00a1b80984c441e69beac9c81000ab414a37f
tree    a2f36780fb46f76ec35b2ab5fa7b70e2ec9abb44
parent  c2e7d1a6ab818feb21e48bca695613b41726b2d7
...
 
 
 
 
1
2
3
...
1
2
3
4
5
6
7
0
@@ -1,3 +1,7 @@
0
+== 0.6.9 / 2008-01-23
0
+ * Bug Fixes
0
+ * Fix Timer condition dedup behavior
0
+
0
 == 0.6.8 / 2008-01-23
0
   * Minor Enhancements
0
     * Warn if a command returns a non-zero exit code
...
20
21
22
23
 
24
25
26
...
45
46
47
48
49
50
51
...
80
81
82
83
84
85
86
...
105
106
107
108
109
110
111
112
 
 
113
114
115
...
119
120
121
122
123
124
125
...
20
21
22
 
23
24
25
26
...
45
46
47
 
48
49
50
...
79
80
81
 
82
83
84
...
103
104
105
 
 
 
 
 
106
107
108
109
110
...
114
115
116
 
117
118
119
0
@@ -20,7 +20,7 @@ module God
0
   class Timer
0
     INTERVAL = 0.25
0
     
0
- attr_reader :events, :pending_events, :conditions, :timer
0
+ attr_reader :events, :pending_events, :timer
0
     
0
     @@timer = nil
0
     
0
@@ -45,7 +45,6 @@ module God
0
     def initialize
0
       @events = []
0
       @pending_events = []
0
- @conditions = []
0
       @pending_mutex = Mutex.new
0
       
0
       @timer = Thread.new do
0
@@ -80,7 +79,6 @@ module God
0
             
0
             # remove all triggered events
0
             triggered.each do |event|
0
- @conditions.delete(event.condition)
0
               @events.delete(event)
0
             end
0
           rescue Exception => e
0
@@ -105,11 +103,8 @@ module God
0
     # Returns nothing
0
     def schedule(condition, delay = condition.interval)
0
       applog(nil, :debug, "timer schedule #{condition} in #{delay} seconds")
0
- unless @conditions.include?(condition)
0
- @pending_mutex.synchronize do
0
- @pending_events << TimerEvent.new(condition, delay)
0
- end
0
- @conditions << condition
0
+ @pending_mutex.synchronize do
0
+ @pending_events << TimerEvent.new(condition, delay)
0
       end
0
     end
0
     
0
@@ -119,7 +114,6 @@ module God
0
     # Returns nothing
0
     def unschedule(condition)
0
       applog(nil, :debug, "timer unschedule #{condition}")
0
- @conditions.delete(condition)
0
     end
0
     
0
     # Trigger the event's condition to be evaluated
...
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
...
41
42
43
 
 
 
 
 
 
 
 
 
 
 
44
45
46
0
@@ -41,17 +41,6 @@ class TestTimer < Test::Unit::TestCase
0
     assert_equal [100, 800, 900, 1000], @t.events.map { |x| x.condition.interval }
0
   end
0
   
0
- def test_unschedule_should_remove_conditions
0
- w = Watch.new
0
- a = stub(:watch => w)
0
- b = stub(:watch => w)
0
- @t.schedule(a, 100)
0
- @t.schedule(b, 200)
0
- assert_equal 2, @t.conditions.size
0
- @t.unschedule(a)
0
- assert_equal 1, @t.conditions.size
0
- end
0
-
0
   def test_time_should_recover_from_exceptions
0
     w = Watch.new
0
     @t.expects(:trigger).raises(Exception.new)

Comments

    No one has commented yet.