* io.c (rb_open_file): encoding in mode string was ignored if perm is
[ruby-svn.git] / sample / drb / holders.rb
blob2d9974f3fc231755702bed16ce0ec89113a9d38f
1 =begin
2 = How to play.
4 ==  with timeridconv:
5   % ruby -d holders.rb
6   druby://yourhost:1234
8   % ruby holderc.rb druby://yourhost:1234
11 ==  without timeridconv:
12   % ruby holders.rb
13   druby://yourhost:1234
15   % ruby holderc.rb druby://yourhost:1234
16 =end
17   
19 require 'drb/drb'
21 class DRbEx3
22   include DRbUndumped
24   def initialize(n)
25     @v = n
26   end
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
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
54 if __FILE__ == $0
55   if $DEBUG
56     require 'drb/timeridconv'
57     DRb.install_id_conv(DRb::TimerIdConv.new(2))
58   end
60   DRb.start_service(nil, DRbEx4.new)
61   puts DRb.uri
62   DRb.thread.join
63 end