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 +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +4 -2
- data/README.md +1 -1
- data/lib/workers/task_group.rb +12 -2
- data/lib/workers/version.rb +1 -1
- data/lib/workers/worker.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b6d69de3bb0d90b8d6ba9c1fd757f3efd8b6c25
|
4
|
+
data.tar.gz: 0c5911c5db1d7191abe82de486c49cbdbd331a6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cc43d9d7779ec4fb95bea731fb584b85151f55198d7c3f3a274923acbc03b32b22b9626d99cccfe7ec214068306951daa33b60d1213e28e43c9f877ef733b74
|
7
|
+
data.tar.gz: 0c3d792a655461008fcfa6954c1a06c1fd27f62ef27cbd3d69f9c1bd9242096f9b986a6bd7cb83fbec52eb747021481e345822d905e14c44a2f4156857d22cd8
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.4.1
|
data/.travis.yml
CHANGED
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
|
-
:
|
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
|
)
|
data/lib/workers/task_group.rb
CHANGED
@@ -42,7 +42,13 @@ module Workers
|
|
42
42
|
@pool.perform { task.run }
|
43
43
|
end
|
44
44
|
|
45
|
-
|
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
|
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
|
data/lib/workers/version.rb
CHANGED
data/lib/workers/worker.rb
CHANGED
@@ -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.
|
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:
|
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.
|
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.
|