pthread 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/pthread/pthread.rb +2 -2
- data/lib/pthread/pthread_executor.rb +2 -2
- data/lib/pthread/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -22,7 +22,7 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
Before using parallel threads you should configure a dRb server:
|
24
24
|
|
25
|
-
|
25
|
+
Pthread::Pthread.start_service 'localhost:12345'
|
26
26
|
|
27
27
|
Pthreads are actual Unix processes. You can add process-workers on the same machine as the main programm by calling:
|
28
28
|
|
data/lib/pthread/pthread.rb
CHANGED
@@ -22,10 +22,10 @@ class Pthread::Pthread
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def initialize(job)
|
25
|
-
@@ts.write([
|
25
|
+
@@ts.write([self.object_id, job[:queue], job[:code], job[:context]])
|
26
26
|
end
|
27
27
|
|
28
28
|
def value
|
29
|
-
@@ts.take([
|
29
|
+
@@ts.take([self.object_id, nil])[1]
|
30
30
|
end
|
31
31
|
end
|
@@ -6,14 +6,14 @@ class Pthread::PthreadExecutor
|
|
6
6
|
ts = DRbObject.new_with_uri("druby://#{host}")
|
7
7
|
|
8
8
|
loop do
|
9
|
-
pthread_id, _, code, context = ts.take([
|
9
|
+
pthread_id, _, code, context = ts.take([nil, queue, nil, nil])
|
10
10
|
|
11
11
|
context && context.each do |a, v|
|
12
12
|
singleton_class.class_eval { attr_accessor a }
|
13
13
|
self.send("#{a}=", context[a])
|
14
14
|
end
|
15
15
|
|
16
|
-
ts.write([
|
16
|
+
ts.write([pthread_id, eval(code)])
|
17
17
|
end
|
18
18
|
rescue DRb::DRbConnError
|
19
19
|
exit 0
|
data/lib/pthread/version.rb
CHANGED