bkoski-interval_exec 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.5.1 2009-01-13
2
+
3
+ * 1 major enhancement:
4
+ * :interval_end_proc now runs in thread immediately after block completes to avoid affecting execution time
5
+
1
6
  == 0.5.0 2009-01-11
2
7
 
3
8
  * 1 major enhancement:
data/lib/interval_exec.rb CHANGED
@@ -4,5 +4,5 @@ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname
4
4
  require File.dirname(__FILE__) + '/interval_exec/interval_exec'
5
5
 
6
6
  module IntervalExecGem
7
- VERSION = '0.5.0'
7
+ VERSION = '0.5.1'
8
8
  end
@@ -19,7 +19,6 @@ class IntervalExec
19
19
  # <b>Notes:</b>
20
20
  # * If code execution ends early, code sleeps until _duration_ is reached.
21
21
  # * Code runs inside a standard +loop+, so +break+ and +next+ keywords can be used to stop execution and skip to next interval
22
- # * IntervalExec doesn't do any exception handling
23
22
  def self.run(duration, overrun_handler, opts = {}, &block)
24
23
  interval_end_proc = opts[:interval_end_proc]
25
24
 
@@ -31,6 +30,8 @@ class IntervalExec
31
30
  end_time = Time.now
32
31
  actual_duration = end_time - start_time
33
32
 
33
+ Thread.new { interval_end_proc.call(actual_duration) } unless interval_end_proc.nil?
34
+
34
35
  if actual_duration < duration
35
36
  Kernel.sleep(duration - actual_duration)
36
37
  else
@@ -42,8 +43,6 @@ class IntervalExec
42
43
  Kernel.sleep(duration - overrun)
43
44
  end
44
45
  end
45
-
46
- interval_end_proc.call(actual_duration) unless interval_end_proc.nil?
47
46
  end
48
47
  end
49
48
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bkoski-interval_exec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Koski
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-12 00:00:00 -08:00
12
+ date: 2009-01-13 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency