pthread 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/lib/pthread/pthread.rb +7 -2
- data/lib/pthread/version.rb +1 -1
- data/spec/pthread/pthread_spec.rb +5 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd1570a572376007e47ce0749ed8bdb17d049390
|
4
|
+
data.tar.gz: 9fdeb6e2ae5d6d0e83a2bd4cdc4d1828689379a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e61ea8d5a55760ab2f9fa00abc8ca07945916e358ce6d21ae7f5ef1579cfba1cf873dce80266c91dadb442c53bed0a59412dbbc43be36d62f7834b49b4b9326
|
7
|
+
data.tar.gz: ac8986d1b4bec161083d3184239dd168dd2e243b9dadae47ced0006209dcbf8425faed7b1d64af41f69e9fd848625e9caa9d1d9523e9d12e47a8a66d8a78b52f
|
data/README.md
CHANGED
data/lib/pthread/pthread.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'rinda/tuplespace'
|
2
2
|
|
3
3
|
class Pthread::Pthread
|
4
|
-
@@ts
|
4
|
+
@@ts = Rinda::TupleSpace.new
|
5
|
+
@@pids = []
|
5
6
|
|
6
7
|
def self.start_service(host)
|
7
8
|
@@host = host
|
@@ -10,7 +11,7 @@ class Pthread::Pthread
|
|
10
11
|
|
11
12
|
def self.add_executors(count = 1, queue=nil)
|
12
13
|
count.times do
|
13
|
-
fork do
|
14
|
+
@@pids << fork do
|
14
15
|
DRb.stop_service
|
15
16
|
Pthread::PthreadExecutor.new(@@host, queue)
|
16
17
|
end
|
@@ -21,6 +22,10 @@ class Pthread::Pthread
|
|
21
22
|
add_executors(1, queue)
|
22
23
|
end
|
23
24
|
|
25
|
+
def self.kill_executors
|
26
|
+
Process.kill 'HUP', *@@pids
|
27
|
+
end
|
28
|
+
|
24
29
|
def initialize(job)
|
25
30
|
@@ts.write([self.object_id, job[:queue], job[:code], job[:context]])
|
26
31
|
end
|
data/lib/pthread/version.rb
CHANGED
@@ -11,7 +11,7 @@ describe Pthread::Pthread do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
before do
|
14
|
-
Pthread::Pthread.start_service 'localhost:
|
14
|
+
Pthread::Pthread.start_service 'localhost:54321'
|
15
15
|
Pthread::Pthread.add_executor 'tasks'
|
16
16
|
end
|
17
17
|
|
@@ -32,4 +32,8 @@ describe Pthread::Pthread do
|
|
32
32
|
expect { pthread.value }.to raise_error ZeroDivisionError
|
33
33
|
end
|
34
34
|
end
|
35
|
+
|
36
|
+
after(:all) do
|
37
|
+
Pthread::Pthread.kill_executors
|
38
|
+
end
|
35
39
|
end
|