~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to sample/drb/name.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2011-09-24 19:16:17 UTC
  • mfrom: (1.1.8 upstream) (13.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20110924191617-o1qz4rcmqjot8zuy
Tags: 1.9.3~rc1-1
* New upstream release: 1.9.3 RC1.
  + Includes load.c fixes. Closes: #639959.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
=begin
2
2
 distributed Ruby --- NamedObject Sample
3
 
        Copyright (c) 2000-2001 Masatoshi SEKI 
 
3
        Copyright (c) 2000-2001 Masatoshi SEKI
4
4
=end
5
5
 
6
6
=begin
7
7
How to play.
8
8
 
9
 
* start server 
 
9
* start server
10
10
 Terminal 1
11
11
 | % ruby name.rb druby://yourhost:7640
12
12
 | druby://yourhost:7640
28
28
 | druby://yourhost:7640
29
29
 | [return] to exit
30
30
 
31
 
* continue client 
 
31
* continue client
32
32
 Terminal 2
33
 
 type [return] 
 
33
 type [return]
34
34
 | 1
35
35
 | 2
36
36
=end
44
44
 
45
45
  def drb_name=(name)
46
46
    @drb_name = name
47
 
    Thread.exclusive do 
 
47
    Thread.exclusive do
48
48
      raise(IndexError, name) if DRbNAMEDICT[name]
49
49
      DRbNAMEDICT[name] = self
50
50
    end
62
62
 
63
63
  def to_id(obj)
64
64
    if obj.kind_of? DRbNamedObject
65
 
      return obj.drb_name 
 
65
      return obj.drb_name
66
66
    else
67
67
      return super
68
68
    end
98
98
    @name['seq'] = seq
99
99
    @name['mutex'] = mutex
100
100
  end
101
 
    
 
101
 
102
102
  def [](k)
103
103
    @name[k]
104
104
  end
108
108
  uri = ARGV.shift
109
109
 
110
110
  name_conv = DRbNamedIdConv.new
111
 
  
 
111
 
112
112
  DRb.install_id_conv(name_conv)
113
113
  DRb.start_service(uri, Front.new)
114
114
  puts DRb.uri