concurrent-ruby 0.1.1.pre.4 → 0.1.1.pre.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/concurrent/executor.rb +3 -1
- data/lib/concurrent/version.rb +1 -1
- data/spec/concurrent/executor_spec.rb +17 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d466fea03aa4bbc40ea569433ab79bccd946e175
|
4
|
+
data.tar.gz: f2e0bab0869b00f0da3ca079eea4055bd45412a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51b483f1cdafc31484283d9e294b4a927170b781b289a02b0ffca6aeb0d92ffebe34ea3e391c0a8bb948aa886d68dea61f030d00651fd4e56c54611bb0eaaf72
|
7
|
+
data.tar.gz: 4c5b7114bade4f3627a735d4ed8e1fbd83636609f67805c23de691167f0dfc9658114d1c3380daa348ed5eb6c848b87605174bd324f4cb0492c161c6288db034
|
data/lib/concurrent/executor.rb
CHANGED
@@ -62,12 +62,13 @@ module Concurrent
|
|
62
62
|
|
63
63
|
execution_interval = opts[:execution] || opts[:execution_interval] || EXECUTION_INTERVAL
|
64
64
|
timeout_interval = opts[:timeout] || opts[:timeout_interval] || TIMEOUT_INTERVAL
|
65
|
+
run_now = opts[:now] || opts[:run_now] || false
|
65
66
|
logger = opts[:logger] || STDOUT_LOGGER
|
66
67
|
block_args = opts[:args] || opts [:arguments] || []
|
67
68
|
|
68
69
|
executor = Thread.new(*block_args) do |*args|
|
70
|
+
sleep(execution_interval) unless run_now == true
|
69
71
|
loop do
|
70
|
-
sleep(execution_interval)
|
71
72
|
break if Thread.current[:stop]
|
72
73
|
begin
|
73
74
|
worker = Thread.new{ yield(*args) }
|
@@ -84,6 +85,7 @@ module Concurrent
|
|
84
85
|
worker = nil
|
85
86
|
end
|
86
87
|
break if Thread.current[:stop]
|
88
|
+
sleep(execution_interval)
|
87
89
|
end
|
88
90
|
end
|
89
91
|
|
data/lib/concurrent/version.rb
CHANGED
@@ -64,7 +64,23 @@ module Concurrent
|
|
64
64
|
|
65
65
|
context 'execution' do
|
66
66
|
|
67
|
-
it '
|
67
|
+
it 'runs the block immediately when the :run_now option is true' do
|
68
|
+
@expected = false
|
69
|
+
@ec = Executor.run('Foo', execution: 500, now: true){ @expected = true }
|
70
|
+
@expected.should be_false
|
71
|
+
sleep(1)
|
72
|
+
@expected.should be_true
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'waits for :execution_interval seconds when the :run_now option is false' do
|
76
|
+
@expected = false
|
77
|
+
@ec = Executor.run('Foo', execution: 0.5, now: false){ @expected = true }
|
78
|
+
@expected.should be_false
|
79
|
+
sleep(1)
|
80
|
+
@expected.should be_true
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'waits for :execution_interval seconds when the :run_now option is not given' do
|
68
84
|
@expected = false
|
69
85
|
@ec = Executor.run('Foo', execution: 0.5){ @expected = true }
|
70
86
|
@expected.should be_false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: concurrent-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.1.pre.
|
4
|
+
version: 0.1.1.pre.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jerry D'Antonio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: functional-ruby
|