threadpool 0.0.1.3 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -0
- data/lib/threadpool.rb +20 -6
- data/threadpool.gemspec +1 -1
- metadata +2 -2
data/README.md
CHANGED
data/lib/threadpool.rb
CHANGED
@@ -19,12 +19,25 @@ module Awakenable
|
|
19
19
|
@awakenable.first.read_nonblock 2048
|
20
20
|
rescue Errno::EAGAIN; end
|
21
21
|
|
22
|
-
|
22
|
+
begin
|
23
|
+
IO.select([@awakenable.first], nil, nil, time)
|
24
|
+
|
25
|
+
true
|
26
|
+
rescue Interrupt
|
27
|
+
false
|
28
|
+
end
|
23
29
|
end
|
24
30
|
|
25
31
|
def wake_up
|
26
32
|
@awakenable ||= IO.pipe
|
27
|
-
|
33
|
+
|
34
|
+
begin
|
35
|
+
@awakenable.last.write 'x'
|
36
|
+
|
37
|
+
true
|
38
|
+
rescue
|
39
|
+
false
|
40
|
+
end
|
28
41
|
end
|
29
42
|
end
|
30
43
|
|
@@ -50,7 +63,8 @@ class ThreadPool
|
|
50
63
|
|
51
64
|
@pool.wake_up
|
52
65
|
else
|
53
|
-
sleep unless die?
|
66
|
+
sleep or break unless die?
|
67
|
+
|
54
68
|
break if die?
|
55
69
|
end
|
56
70
|
end
|
@@ -109,11 +123,11 @@ class ThreadPool
|
|
109
123
|
|
110
124
|
@watcher.process {
|
111
125
|
loop do
|
112
|
-
sleep if @queue.empty?
|
113
|
-
next
|
126
|
+
sleep or break if @queue.empty?
|
127
|
+
next if @queue.empty?
|
114
128
|
|
115
129
|
begin
|
116
|
-
worker = @pool.find(&:available?) or sleep
|
130
|
+
worker = @pool.find(&:available?) or sleep or break
|
117
131
|
end until worker
|
118
132
|
|
119
133
|
break if die?
|
data/threadpool.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: threadpool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
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-
|
12
|
+
date: 2011-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email: meh@paranoici.org
|