workers 0.6.0 → 0.6.1

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: 50e412eae6d1bdf77fe6588ffc6a8d2412f739f7
4
- data.tar.gz: ab20ac26b42dd524faa2d0d1171e6887de2e3bbf
3
+ metadata.gz: 8b6d69de3bb0d90b8d6ba9c1fd757f3efd8b6c25
4
+ data.tar.gz: 0c5911c5db1d7191abe82de486c49cbdbd331a6c
5
5
  SHA512:
6
- metadata.gz: d22b5c5fb81b2b5b7105c1d237b2d9b779af7b2ef9cad993cd80c9b012a851390d851ec976497f51d87a7cbc2265d31e3712c4d2b2d2572da65c7ed8fa9fbec7
7
- data.tar.gz: 3c44a7b8cc2e9943e919cb02e231f2d25511b5b24a4df1be847ef7e9c3b7ae083d07d35b3f1f99c25d5e8784745953300301ebecce7b67c155de3182ca6ecd94
6
+ metadata.gz: 8cc43d9d7779ec4fb95bea731fb584b85151f55198d7c3f3a274923acbc03b32b22b9626d99cccfe7ec214068306951daa33b60d1213e28e43c9f877ef733b74
7
+ data.tar.gz: 0c3d792a655461008fcfa6954c1a06c1fd27f62ef27cbd3d69f9c1bd9242096f9b986a6bd7cb83fbec52eb747021481e345822d905e14c44a2f4156857d22cd8
@@ -1 +1 @@
1
- 2.2.2
1
+ 2.4.1
@@ -1,4 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.2
4
- before_install: gem install bundler -v 1.10.5
3
+ - 2.4.0
4
+ - 2.3.3
5
+ - 2.2.6
6
+ - 2.1.10
data/README.md CHANGED
@@ -109,7 +109,7 @@ This method uses a mutex so you can serialize portions of your tasks that aren't
109
109
  task = Workers::Task.new(
110
110
  :logger => nil, # Ruby logger instance.
111
111
  :on_perform => proc {}, # Required option. Block of code to run.
112
- :args => [], # Array of arguments passed to the 'perform' block.
112
+ :input => [], # Array of arguments passed to the 'perform' block.
113
113
  :on_finished => nil, # Callback to execute after attempting to run the task.
114
114
  :max_tries => 1, # Number of times to try completing the task (without an exception).
115
115
  )
@@ -42,7 +42,13 @@ module Workers
42
42
  @pool.perform { task.run }
43
43
  end
44
44
 
45
- @conditional.wait(@internal_lock)
45
+ loop do
46
+ @conditional.wait(@internal_lock)
47
+ # The wait can return even if nothing called @conditional.signal,
48
+ # so we need to check to see if the condition actually changed.
49
+ # See https://github.com/chadrem/workers/issues/7
50
+ break if all_tasks_finished?
51
+ end
46
52
  end
47
53
 
48
54
  @tasks.all? { |t| t.succeeded? }
@@ -98,10 +104,14 @@ module Workers
98
104
  def finished(task)
99
105
  @internal_lock.synchronize do
100
106
  @finished_count += 1
101
- @conditional.signal if @finished_count >= @tasks.count
107
+ @conditional.signal if all_tasks_finished?
102
108
  end
103
109
 
104
110
  nil
105
111
  end
112
+
113
+ def all_tasks_finished?
114
+ @finished_count >= @tasks.count
115
+ end
106
116
  end
107
117
  end
@@ -1,3 +1,3 @@
1
1
  module Workers
2
- VERSION = '0.6.0'
2
+ VERSION = '0.6.1'
3
3
  end
@@ -8,9 +8,9 @@ module Workers
8
8
  def initialize(options = {})
9
9
  @logger = Workers::LogProxy.new(options[:logger])
10
10
  @input_queue = options[:input_queue] || Queue.new
11
- @thread = Thread.new { start_event_loop }
12
11
  @on_exception = options[:on_exception]
13
12
  @run = true
13
+ @thread = Thread.new { start_event_loop }
14
14
 
15
15
  nil
16
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Remesch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-23 00:00:00.000000000 Z
11
+ date: 2017-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  version: '0'
104
104
  requirements: []
105
105
  rubyforge_project:
106
- rubygems_version: 2.4.5
106
+ rubygems_version: 2.6.11
107
107
  signing_key:
108
108
  specification_version: 4
109
109
  summary: A Ruby gem for performing work in background threads.