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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c49a338e0ef3a2fa13c34e26ea4a6bf0a6209b8
4
- data.tar.gz: c5294b8b92b533b6b217c75b926b1193940ba414
3
+ metadata.gz: d466fea03aa4bbc40ea569433ab79bccd946e175
4
+ data.tar.gz: f2e0bab0869b00f0da3ca079eea4055bd45412a7
5
5
  SHA512:
6
- metadata.gz: e3361368c418fd5c935b3cf48908ba06ec1d91383f0200472a9129e7d8c36832c4613823cf5c165d20eb9e504c5a6d7439fa9b5e3f92858c8f1359e1f4504c3d
7
- data.tar.gz: a2724fd6ca19e2b3639b08124ff33a575cbe09d249e56aeab0083dede0b24bf3d40ee8c712f728f0cdf221fde363d931a2b9a728b2291f55c3ab1fa524304fac
6
+ metadata.gz: 51b483f1cdafc31484283d9e294b4a927170b781b289a02b0ffca6aeb0d92ffebe34ea3e391c0a8bb948aa886d68dea61f030d00651fd4e56c54611bb0eaaf72
7
+ data.tar.gz: 4c5b7114bade4f3627a735d4ed8e1fbd83636609f67805c23de691167f0dfc9658114d1c3380daa348ed5eb6c848b87605174bd324f4cb0492c161c6288db034
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module Concurrent
2
- VERSION = '0.1.1.pre.4'
2
+ VERSION = '0.1.1.pre.5'
3
3
  end
@@ -64,7 +64,23 @@ module Concurrent
64
64
 
65
65
  context 'execution' do
66
66
 
67
- it 'waits for #execution_interval seconds before executing the block' do
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
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-13 00:00:00.000000000 Z
11
+ date: 2013-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: functional-ruby