iprocess 5.0.2 → 5.0.3
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.
- data/Gemfile +5 -0
- data/README.md +40 -34
- data/iprocess.gemspec +0 -4
- data/lib/iprocess/version.rb +1 -1
- metadata +2 -66
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -26,9 +26,11 @@ In this example three subprocesses are spawned. The return value of the block,
|
|
26
26
|
even though executed in a subprocess, is returned to the parent process as long
|
27
27
|
as it may be serialized by Marshal(or the serializer of your choice, this is
|
28
28
|
configurable):
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
messages = IProcess.spawn(3) { {msg: "hello"} }
|
32
|
+
p messages # => [{msg: "hello"}, {msg: "hello"}, {msg: "hello"}]
|
33
|
+
```
|
32
34
|
|
33
35
|
__2.__
|
34
36
|
|
@@ -36,40 +38,44 @@ You can spawn a subprocess with a block or with any object that responds to
|
|
36
38
|
`#call`. If you had a worker that was too complicated as a block you could
|
37
39
|
try this:
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
41
|
+
```ruby
|
42
|
+
class Worker
|
43
|
+
def initialize
|
44
|
+
@num = 1
|
45
|
+
end
|
46
|
+
|
47
|
+
def call
|
48
|
+
@num + 1
|
49
|
+
end
|
50
|
+
end
|
51
|
+
IProcess.spawn 5, Worker.new # => [2, 2, 2, 2, 2]
|
52
|
+
```
|
50
53
|
__3.__
|
51
54
|
|
52
55
|
A demo of how you would spawn two subprocesses asynchronously.
|
53
|
-
|
54
|
-
communicate by using an API tailored to asynchrounous programming.
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
56
|
+
Although the subprocesses are spawned asynchrounsly you can still
|
57
|
+
communicate by using an API tailored to asynchrounous programming. The example
|
58
|
+
may not be the best, though:
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
class Inbox
|
62
|
+
def initialize
|
63
|
+
@msgs = []
|
64
|
+
end
|
65
|
+
|
66
|
+
def msgs
|
67
|
+
@msgs
|
68
|
+
end
|
69
|
+
|
70
|
+
def recv(msg)
|
71
|
+
@msgs << msg
|
72
|
+
end
|
73
|
+
end
|
74
|
+
inbox = Inbox.new
|
75
|
+
IProcess.spawn!(2, Inbox.new) { Process.pid }
|
76
|
+
sleep 0.1
|
77
|
+
p inbox.msgs
|
78
|
+
```
|
73
79
|
|
74
80
|
__SERIALIZERS__
|
75
81
|
|
data/iprocess.gemspec
CHANGED
@@ -21,8 +21,4 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.required_ruby_version = '>= 1.9.2'
|
22
22
|
|
23
23
|
s.add_runtime_dependency 'ichannel', '~> 1.0.0'
|
24
|
-
s.add_development_dependency 'yard' , '~> 0.7'
|
25
|
-
s.add_development_dependency 'minitest', '~> 2.6'
|
26
|
-
s.add_development_dependency 'rake', '~> 0.9.2'
|
27
|
-
s.add_development_dependency 'kramdown'
|
28
24
|
end
|
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.0.3
|
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-01-
|
12
|
+
date: 2013-01-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ichannel
|
@@ -27,70 +27,6 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 1.0.0
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: yard
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0.7'
|
38
|
-
type: :development
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0.7'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: minitest
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '2.6'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '2.6'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: rake
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ~>
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 0.9.2
|
70
|
-
type: :development
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: 0.9.2
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: kramdown
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ! '>='
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '0'
|
86
|
-
type: :development
|
87
|
-
prerelease: false
|
88
|
-
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ! '>='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '0'
|
94
30
|
description: A number of abstractions on top of spawning subprocesses and interprocess
|
95
31
|
communication.
|
96
32
|
email: rob@flowof.info
|