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 +5 -0
- data/lib/interval_exec.rb +1 -1
- data/lib/interval_exec/interval_exec.rb +2 -3
- metadata +2 -2
data/History.txt
CHANGED
data/lib/interval_exec.rb
CHANGED
@@ -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.
|
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
|
+
date: 2009-01-13 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|