workqueue 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/workqueue.rb +5 -14
- data/lib/workqueue/version.rb +1 -1
- metadata +4 -4
data/lib/workqueue.rb
CHANGED
@@ -17,7 +17,6 @@ class WorkQueue
|
|
17
17
|
def initialize(init_queue=[], opts={}, &job)
|
18
18
|
@job = job
|
19
19
|
@queue = Queue.new
|
20
|
-
@mutex = Mutex.new
|
21
20
|
|
22
21
|
opts.each { |k, v| send(:"#{k}=", v) }
|
23
22
|
|
@@ -32,17 +31,9 @@ class WorkQueue
|
|
32
31
|
def work!
|
33
32
|
loop do
|
34
33
|
begin
|
35
|
-
|
36
|
-
|
37
|
-
payload
|
38
|
-
|
39
|
-
@mutex.synchronize {
|
40
|
-
unless @aborted or (@joined and queue.empty?)
|
41
|
-
payload, index = queue.shift
|
42
|
-
end
|
43
|
-
}
|
44
|
-
|
45
|
-
break if payload.nil?
|
34
|
+
break if @aborted
|
35
|
+
payload, index = queue.shift
|
36
|
+
break if payload == :__break!
|
46
37
|
|
47
38
|
aggregate[index] = job.call(payload)
|
48
39
|
rescue Exception
|
@@ -53,7 +44,7 @@ class WorkQueue
|
|
53
44
|
end
|
54
45
|
|
55
46
|
def abort!
|
56
|
-
@
|
47
|
+
@aborted = true
|
57
48
|
end
|
58
49
|
|
59
50
|
def run
|
@@ -76,7 +67,7 @@ class WorkQueue
|
|
76
67
|
end
|
77
68
|
|
78
69
|
def join
|
79
|
-
|
70
|
+
concat([:__break!] * size)
|
80
71
|
|
81
72
|
workers.each(&:join)
|
82
73
|
|
data/lib/workqueue/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: workqueue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-11-
|
12
|
+
date: 2011-11-09 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! ' A description will be forthcoming
|
15
15
|
|
@@ -38,7 +38,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
38
38
|
version: '0'
|
39
39
|
segments:
|
40
40
|
- 0
|
41
|
-
hash:
|
41
|
+
hash: 3748006813940409733
|
42
42
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
43
|
none: false
|
44
44
|
requirements:
|
@@ -47,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
47
|
version: '0'
|
48
48
|
segments:
|
49
49
|
- 0
|
50
|
-
hash:
|
50
|
+
hash: 3748006813940409733
|
51
51
|
requirements: []
|
52
52
|
rubyforge_project: workqueue
|
53
53
|
rubygems_version: 1.8.10
|