contender 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/contender/countdown_latch.rb +4 -2
- data/lib/contender/pool/thread_pool_executor.rb +12 -7
- data/lib/contender/version.rb +1 -1
- metadata +14 -12
- checksums.yaml +0 -7
@@ -26,7 +26,7 @@ module Contender
|
|
26
26
|
def countdown
|
27
27
|
@mutex.synchronize do
|
28
28
|
@count = @count.pred if @count > 0
|
29
|
-
@condition.broadcast
|
29
|
+
@condition.broadcast if @count == 0
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -34,11 +34,13 @@ module Contender
|
|
34
34
|
#
|
35
35
|
# @api public
|
36
36
|
# @param [Float] timeout
|
37
|
-
# @return [
|
37
|
+
# @return [Boolean] True if the latch reached zero, false if the timeout was reached
|
38
38
|
def await(timeout = nil)
|
39
39
|
@mutex.synchronize do
|
40
40
|
return if @count == 0
|
41
41
|
@condition.wait @mutex, timeout
|
42
|
+
|
43
|
+
@count == 0
|
42
44
|
end
|
43
45
|
end
|
44
46
|
end # CountdownLatch
|
@@ -72,7 +72,10 @@ module Contender
|
|
72
72
|
# @api public
|
73
73
|
# @return [undefined]
|
74
74
|
def start
|
75
|
-
|
75
|
+
@mutex.synchronize do
|
76
|
+
return unless inactive?
|
77
|
+
@state = :starting
|
78
|
+
end
|
76
79
|
|
77
80
|
start_workers @options.fetch(:size)
|
78
81
|
@state = :active
|
@@ -83,9 +86,10 @@ module Contender
|
|
83
86
|
# @api public
|
84
87
|
# @return [undefined]
|
85
88
|
def shutdown
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
+
@mutex.synchronize do
|
90
|
+
return unless active?
|
91
|
+
@state = :shutdown
|
92
|
+
end
|
89
93
|
|
90
94
|
# TODO This is not ideal
|
91
95
|
until @queue.empty?
|
@@ -108,9 +112,10 @@ module Contender
|
|
108
112
|
# @api public
|
109
113
|
# @return [undefined]
|
110
114
|
def shutdown!
|
111
|
-
|
112
|
-
|
113
|
-
|
115
|
+
@mutex.synchronize do
|
116
|
+
return unless active?
|
117
|
+
@state = :shutdown_now
|
118
|
+
end
|
114
119
|
|
115
120
|
@workers.each do |worker|
|
116
121
|
worker.interrupt
|
data/lib/contender/version.rb
CHANGED
metadata
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contender
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.1
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Ian Unruh
|
8
|
-
autorequire:
|
9
|
+
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
12
|
date: 2013-06-13 00:00:00.000000000 Z
|
@@ -16,22 +17,21 @@ executables: []
|
|
16
17
|
extensions: []
|
17
18
|
extra_rdoc_files: []
|
18
19
|
files:
|
20
|
+
- lib/contender.rb
|
19
21
|
- lib/contender/countdown_latch.rb
|
20
22
|
- lib/contender/direct_executor.rb
|
21
23
|
- lib/contender/errors.rb
|
22
24
|
- lib/contender/executor.rb
|
25
|
+
- lib/contender/pool.rb
|
26
|
+
- lib/contender/version.rb
|
23
27
|
- lib/contender/pool/pool_worker.rb
|
24
28
|
- lib/contender/pool/task.rb
|
25
29
|
- lib/contender/pool/task_queue.rb
|
26
30
|
- lib/contender/pool/thread_pool_executor.rb
|
27
|
-
- lib/contender/pool.rb
|
28
|
-
- lib/contender/version.rb
|
29
|
-
- lib/contender.rb
|
30
31
|
homepage: https://github.com/ianunruh/contender
|
31
32
|
licenses:
|
32
33
|
- Apache 2.0
|
33
|
-
|
34
|
-
post_install_message:
|
34
|
+
post_install_message:
|
35
35
|
rdoc_options: []
|
36
36
|
require_paths:
|
37
37
|
- lib
|
@@ -40,16 +40,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
40
40
|
- - '>='
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '0'
|
43
|
+
none: false
|
43
44
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
45
|
requirements:
|
45
46
|
- - '>='
|
46
47
|
- !ruby/object:Gem::Version
|
47
48
|
version: '0'
|
49
|
+
none: false
|
48
50
|
requirements: []
|
49
|
-
rubyforge_project:
|
50
|
-
rubygems_version:
|
51
|
-
signing_key:
|
52
|
-
specification_version:
|
51
|
+
rubyforge_project:
|
52
|
+
rubygems_version: 1.8.24
|
53
|
+
signing_key:
|
54
|
+
specification_version: 3
|
53
55
|
summary: Simple framework for managing in-process execution
|
54
56
|
test_files: []
|
55
|
-
has_rdoc:
|
57
|
+
has_rdoc:
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 4277ce364374a3fc397165e20f7775c84828225c
|
4
|
-
data.tar.gz: f8c915d431b9d64ae31a9a9470e78ee83ba8df7d
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 6f252c5ef6200b03e51f3a35edddc150d03ddd01f20cf77f7a7b9d102114f499df03a07db0a5c8833fa3af55a0ad27e0a39ce9aa616ca0edc229853e7741f56c
|
7
|
-
data.tar.gz: 9c65d1d8d32808f2afcb0a66ffa41d995b7af142faeda839fd588d2c833582d63f3421c981bb759f46842e74987950d2f1aed48bb9e3bf892c961f43f26a0a25
|