slave 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/sample/c.rb ADDED
@@ -0,0 +1,109 @@
1
+ $:.unshift 'lib'
2
+ $:.unshift '../lib'
3
+
4
+ require 'yaml'
5
+ require 'slave'
6
+
7
+ class Incrementer
8
+ attr :decrementer, true
9
+ def increment n
10
+ n + 1
11
+ end
12
+ def decrement n
13
+ @decrementer.decrement n
14
+ end
15
+ end
16
+
17
+ class Decrementer
18
+ attr :incrementer, true
19
+ def increment n
20
+ @incrementer.increment n
21
+ end
22
+ def decrement n
23
+ n - 1
24
+ end
25
+ end
26
+
27
+
28
+ #
29
+ #
30
+ # here we set up a triangle of communicating processes
31
+ #
32
+ # incrementer------decrementer
33
+ # \ /
34
+ # \ /
35
+ # \ /
36
+ # \ /
37
+ # \ /
38
+ # parent
39
+ #
40
+ #
41
+
42
+ incrementer_slave = Slave::new Incrementer::new
43
+ incrementer = incrementer_slave.object
44
+
45
+ puts '---'
46
+ puts 'incrementer :'
47
+ puts " sockect : #{ incrementer_slave.socket.inspect }"
48
+ puts " uri : #{ incrementer_slave.uri.inspect }"
49
+ puts " pid : #{ incrementer_slave.pid.inspect }"
50
+ puts
51
+
52
+ decrementer_slave = Slave::new Decrementer::new
53
+ decrementer = decrementer_slave.object
54
+
55
+ puts '---'
56
+ puts 'decrementer :'
57
+ puts " sockect : #{ decrementer_slave.socket.inspect }"
58
+ puts " uri : #{ decrementer_slave.uri.inspect }"
59
+ puts " pid : #{ decrementer_slave.pid.inspect }"
60
+ puts
61
+
62
+ #
63
+ # connect incrementer and decrementer
64
+ #
65
+
66
+ incrementer.decrementer = decrementer
67
+ decrementer.incrementer = incrementer
68
+
69
+ #
70
+ # now we can call methods on each drb object, and they can also call methods on
71
+ # each other
72
+ #
73
+
74
+ n = 0
75
+
76
+ #n = incrementer.increment n
77
+ #p n #=> 1
78
+ y "incrementer.increment(#{ n })" => (n = incrementer.increment(n))
79
+
80
+ #n = decrementer.decrement n
81
+ #p n #=> 0
82
+ y "decrementer.decrement(#{ n })" => (n = decrementer.decrement(n))
83
+
84
+ #n = decrementer.increment n
85
+ #p n #=> 1
86
+ y "decrementer.increment(#{ n })" => (n = decrementer.increment(n))
87
+
88
+ #n = incrementer.decrement n
89
+ #p n #=> 0
90
+ y "incrementer.decrement(#{ n })" => (n = incrementer.decrement(n))
91
+
92
+ #
93
+ # we can explicitly shutdown certain slaves
94
+ #
95
+
96
+ incrementer_slave.shutdown
97
+ #n = decrementer.decrement 43
98
+ #p n #=> 42
99
+ n = 43
100
+ y "decrementer.decrement(#{ n })" => (n = decrementer.decrement(n))
101
+
102
+ #
103
+ # Slaves cannot live beyond their parent so we simply exit and all living slaves
104
+ # will eventually die. how long it takes to die is determined by the
105
+ # pulse_rate - the next time the Heartbeat trys to ping the parent the Slave
106
+ # will die.
107
+ #
108
+
109
+ exit
File without changes
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: slave
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.0
7
- date: 2006-05-27 00:00:00.000000 -06:00
6
+ version: 0.0.1
7
+ date: 2006-06-08 00:00:00.000000 -06:00
8
8
  summary: slave
9
9
  require_paths:
10
10
  - lib
@@ -29,39 +29,41 @@ cert_chain:
29
29
  authors:
30
30
  - Ara T. Howard
31
31
  files:
32
+ - HISTORY
32
33
  - install.rb
33
- - lib
34
34
  - sample
35
+ - lib
36
+ - README
35
37
  - rdoc.cmd
38
+ - slave-0.0.1.gem
36
39
  - doc
37
- - VERSION
38
- - README
39
40
  - gemspec.rb
40
- - slave-0.0.0.gem
41
- - lib/slave-0.0.0.rb
42
- - lib/slave.rb
43
41
  - sample/a.rb
44
- - doc/created.rid
45
- - doc/dot
46
- - doc/rdoc-style.css
42
+ - sample/b.rb
43
+ - sample/c.rb
44
+ - lib/slave-0.0.1.rb
45
+ - lib/slave.rb
46
+ - doc/index.html
47
47
  - doc/files
48
- - doc/classes
49
- - doc/fr_file_index.html
50
48
  - doc/fr_class_index.html
49
+ - doc/created.rid
51
50
  - doc/fr_method_index.html
52
- - doc/index.html
53
- - doc/dot/f_0.dot
54
- - doc/dot/f_0.jpg
55
- - doc/dot/f_1.dot
56
- - doc/dot/f_1.jpg
57
- - doc/dot/f_2.dot
58
- - doc/dot/f_2.jpg
59
- - doc/files/VERSION.html
51
+ - doc/fr_file_index.html
52
+ - doc/rdoc-style.css
53
+ - doc/dot
54
+ - doc/classes
60
55
  - doc/files/lib
56
+ - doc/files/VERSION.html
61
57
  - doc/files/README.html
62
58
  - doc/files/lib/slave_rb.html
63
- - doc/classes/Slave.html
59
+ - doc/dot/f_2.jpg
60
+ - doc/dot/f_0.dot
61
+ - doc/dot/f_1.jpg
62
+ - doc/dot/f_2.dot
63
+ - doc/dot/f_1.dot
64
+ - doc/dot/f_0.jpg
64
65
  - doc/classes/Slave
66
+ - doc/classes/Slave.html
65
67
  - doc/classes/Slave/Heartbeat.html
66
68
  test_files: []
67
69
  rdoc_options: []
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.0