iprocess 5.0.5 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -15
- data/lib/iprocess.rb +2 -3
- data/lib/iprocess/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -54,27 +54,17 @@ __3.__
|
|
54
54
|
|
55
55
|
A demo of how you would spawn two subprocesses asynchronously.
|
56
56
|
Although the subprocesses are spawned asynchrounsly you can still
|
57
|
-
communicate by
|
58
|
-
may not be the best, though:
|
57
|
+
communicate by defining a callback the subprocess can call when it completes.
|
58
|
+
The example may not be the best, though:
|
59
59
|
|
60
60
|
```ruby
|
61
61
|
class Inbox
|
62
|
-
def
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
def msgs
|
67
|
-
@msgs
|
68
|
-
end
|
69
|
-
|
70
|
-
def recv(msg)
|
71
|
-
@msgs << msg
|
62
|
+
def recv(pid)
|
63
|
+
puts "'#{pid}' has finished!"
|
72
64
|
end
|
73
65
|
end
|
74
66
|
inbox = Inbox.new
|
75
|
-
IProcess.spawn!(2,
|
76
|
-
sleep 0.1
|
77
|
-
p inbox.msgs
|
67
|
+
IProcess.spawn!(2, inbox) { Process.pid }
|
78
68
|
```
|
79
69
|
|
80
70
|
__SERIALIZERS__
|
data/lib/iprocess.rb
CHANGED
@@ -54,9 +54,8 @@ class IProcess
|
|
54
54
|
def self.spawn!(number_of, inbox, obj = nil, &worker)
|
55
55
|
forks = fork number_of, obj, &worker
|
56
56
|
forks.each do |subprocess|
|
57
|
-
Thread.new
|
58
|
-
|
59
|
-
end
|
57
|
+
t = Thread.new { inbox.recv subprocess.result }
|
58
|
+
at_exit { t.join }
|
60
59
|
end
|
61
60
|
end
|
62
61
|
|
data/lib/iprocess/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iprocess
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0
|
4
|
+
version: 5.1.0
|
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: 2013-
|
12
|
+
date: 2013-02-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ichannel
|