repo.or.cz
/
ruby-svn.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
history
|
raw
|
HEAD
* io.c (rb_open_file): encoding in mode string was ignored if perm is
[ruby-svn.git]
/
sample
/
drb
/
holders.rb
blob
2d9974f3fc231755702bed16ce0ec89113a9d38f
1
=begin
2
= How to play.
3
4
== with timeridconv:
5
% ruby -d holders.rb
6
druby://yourhost:1234
7
8
% ruby holderc.rb druby://yourhost:1234
9
10
11
== without timeridconv:
12
% ruby holders.rb
13
druby://yourhost:1234
14
15
% ruby holderc.rb druby://yourhost:1234
16
=end
17
18
19
require 'drb/drb'
20
21
class DRbEx3
22
include DRbUndumped
23
24
def initialize(n)
25
@v = n
26
end
27
28
def sample(list)
29
sum = 0
30
list.each do |e|
31
sum += e.to_i
32
end
33
@v * sum
34
end
35
end
36
37
class DRbEx4
38
include DRbUndumped
39
40
def initialize
41
@curr = 1
42
end
43
44
def gen
45
begin
46
@curr += 1
47
DRbEx3.new(@curr)
48
ensure
49
GC.start
50
end
51
end
52
end
53
54
if __FILE__ == $0
55
if $DEBUG
56
require 'drb/timeridconv'
57
DRb.install_id_conv(DRb::TimerIdConv.new(2))
58
end
59
60
DRb.start_service(nil, DRbEx4.new)
61
puts DRb.uri
62
DRb.thread.join
63
end