dat-worker-pool 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/bench/report.rb +130 -0
- data/bench/report.txt +7 -0
- data/dat-worker-pool.gemspec +1 -1
- data/lib/dat-worker-pool.rb +38 -187
- data/lib/dat-worker-pool/default_queue.rb +60 -0
- data/lib/dat-worker-pool/locked_object.rb +60 -0
- data/lib/dat-worker-pool/queue.rb +71 -48
- data/lib/dat-worker-pool/runner.rb +196 -0
- data/lib/dat-worker-pool/version.rb +1 -1
- data/lib/dat-worker-pool/worker.rb +251 -72
- data/lib/dat-worker-pool/worker_pool_spy.rb +39 -53
- data/test/helper.rb +13 -0
- data/test/support/factory.rb +15 -0
- data/test/support/thread_spies.rb +83 -0
- data/test/system/dat-worker-pool_tests.rb +399 -0
- data/test/unit/dat-worker-pool_tests.rb +132 -255
- data/test/unit/default_queue_tests.rb +217 -0
- data/test/unit/locked_object_tests.rb +260 -0
- data/test/unit/queue_tests.rb +95 -72
- data/test/unit/runner_tests.rb +365 -0
- data/test/unit/worker_pool_spy_tests.rb +95 -102
- data/test/unit/worker_tests.rb +819 -153
- metadata +27 -12
- data/test/system/use_worker_pool_tests.rb +0 -34
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dat-worker-pool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 6
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.6.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Collin Redding
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2015-
|
19
|
+
date: 2015-11-24 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
requirement: &id001 !ruby/object:Gem::Requirement
|
@@ -29,9 +29,9 @@ dependencies:
|
|
29
29
|
- 1
|
30
30
|
- 2
|
31
31
|
version: "1.2"
|
32
|
-
version_requirements: *id001
|
33
32
|
type: :runtime
|
34
33
|
name: SystemTimer
|
34
|
+
version_requirements: *id001
|
35
35
|
prerelease: false
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
@@ -39,14 +39,14 @@ dependencies:
|
|
39
39
|
requirements:
|
40
40
|
- - ~>
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
hash:
|
42
|
+
hash: 29
|
43
43
|
segments:
|
44
44
|
- 2
|
45
|
-
-
|
46
|
-
version: "2.
|
47
|
-
version_requirements: *id002
|
45
|
+
- 15
|
46
|
+
version: "2.15"
|
48
47
|
type: :development
|
49
48
|
name: assert
|
49
|
+
version_requirements: *id002
|
50
50
|
prerelease: false
|
51
51
|
description: A simple thread pool for processing generic 'work'
|
52
52
|
email:
|
@@ -64,17 +64,27 @@ files:
|
|
64
64
|
- LICENSE.txt
|
65
65
|
- README.md
|
66
66
|
- Rakefile
|
67
|
+
- bench/report.rb
|
68
|
+
- bench/report.txt
|
67
69
|
- dat-worker-pool.gemspec
|
68
70
|
- lib/dat-worker-pool.rb
|
71
|
+
- lib/dat-worker-pool/default_queue.rb
|
72
|
+
- lib/dat-worker-pool/locked_object.rb
|
69
73
|
- lib/dat-worker-pool/queue.rb
|
74
|
+
- lib/dat-worker-pool/runner.rb
|
70
75
|
- lib/dat-worker-pool/version.rb
|
71
76
|
- lib/dat-worker-pool/worker.rb
|
72
77
|
- lib/dat-worker-pool/worker_pool_spy.rb
|
73
78
|
- log/.gitkeep
|
74
79
|
- test/helper.rb
|
75
|
-
- test/
|
80
|
+
- test/support/factory.rb
|
81
|
+
- test/support/thread_spies.rb
|
82
|
+
- test/system/dat-worker-pool_tests.rb
|
76
83
|
- test/unit/dat-worker-pool_tests.rb
|
84
|
+
- test/unit/default_queue_tests.rb
|
85
|
+
- test/unit/locked_object_tests.rb
|
77
86
|
- test/unit/queue_tests.rb
|
87
|
+
- test/unit/runner_tests.rb
|
78
88
|
- test/unit/worker_pool_spy_tests.rb
|
79
89
|
- test/unit/worker_tests.rb
|
80
90
|
- tmp/.gitkeep
|
@@ -107,14 +117,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
117
|
requirements: []
|
108
118
|
|
109
119
|
rubyforge_project:
|
110
|
-
rubygems_version: 1.8.
|
120
|
+
rubygems_version: 1.8.25
|
111
121
|
signing_key:
|
112
122
|
specification_version: 3
|
113
123
|
summary: A simple thread pool for processing generic 'work'
|
114
124
|
test_files:
|
115
125
|
- test/helper.rb
|
116
|
-
- test/
|
126
|
+
- test/support/factory.rb
|
127
|
+
- test/support/thread_spies.rb
|
128
|
+
- test/system/dat-worker-pool_tests.rb
|
117
129
|
- test/unit/dat-worker-pool_tests.rb
|
130
|
+
- test/unit/default_queue_tests.rb
|
131
|
+
- test/unit/locked_object_tests.rb
|
118
132
|
- test/unit/queue_tests.rb
|
133
|
+
- test/unit/runner_tests.rb
|
119
134
|
- test/unit/worker_pool_spy_tests.rb
|
120
135
|
- test/unit/worker_tests.rb
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'assert'
|
2
|
-
require 'dat-worker-pool'
|
3
|
-
|
4
|
-
class UseWorkerPoolTests < Assert::Context
|
5
|
-
|
6
|
-
desc "defining a custom worker pool"
|
7
|
-
setup do
|
8
|
-
@mutex = Mutex.new
|
9
|
-
@results = []
|
10
|
-
@work_pool = DatWorkerPool.new(1, 2, !!ENV['DEBUG']) do |work|
|
11
|
-
@mutex.synchronize{ @results << (work * 100) }
|
12
|
-
end
|
13
|
-
@work_pool.start
|
14
|
-
end
|
15
|
-
|
16
|
-
should "be able to add work, have it processed and stop the pool" do
|
17
|
-
@work_pool.add_work 1
|
18
|
-
@work_pool.add_work 5
|
19
|
-
@work_pool.add_work 2
|
20
|
-
@work_pool.add_work 4
|
21
|
-
@work_pool.add_work 3
|
22
|
-
|
23
|
-
sleep 0.1 # allow the worker threads to run
|
24
|
-
|
25
|
-
@work_pool.shutdown(1)
|
26
|
-
|
27
|
-
assert_includes 100, @results
|
28
|
-
assert_includes 200, @results
|
29
|
-
assert_includes 300, @results
|
30
|
-
assert_includes 400, @results
|
31
|
-
assert_includes 500, @results
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|