summaryrefslogtreecommitdiff
path: root/sample/drb
diff options
context:
space:
mode:
Diffstat (limited to 'sample/drb')
-rw-r--r--sample/drb/README.ja.rdoc2
-rw-r--r--sample/drb/README.rdoc2
-rw-r--r--sample/drb/dchats.rb3
-rw-r--r--sample/drb/dhasen.rb3
-rw-r--r--sample/drb/dlogd.rb3
-rw-r--r--sample/drb/dqueue.rb3
-rw-r--r--sample/drb/http0serv.rb13
-rw-r--r--sample/drb/name.rb8
-rw-r--r--sample/drb/old_tuplespace.rb4
-rw-r--r--sample/drb/ring_echo.rb1
-rw-r--r--sample/drb/simpletuple.rb2
11 files changed, 18 insertions, 26 deletions
diff --git a/sample/drb/README.ja.rdoc b/sample/drb/README.ja.rdoc
index 3ab70f3369..1697b1b704 100644
--- a/sample/drb/README.ja.rdoc
+++ b/sample/drb/README.ja.rdoc
@@ -50,7 +50,7 @@
* drbssl_s.rb
* drbssl_c.rb
-* DRbProtoclの追加例
+* DRbProtocolの追加例
* http0.rb
* http0serv.rb
diff --git a/sample/drb/README.rdoc b/sample/drb/README.rdoc
index 80ae910a8a..fcb4182410 100644
--- a/sample/drb/README.rdoc
+++ b/sample/drb/README.rdoc
@@ -47,7 +47,7 @@
* drbssl_s.rb
* drbssl_c.rb
-* add DRbProtocl
+* add DRbProtocol
* http0.rb
* http0serv.rb
diff --git a/sample/drb/dchats.rb b/sample/drb/dchats.rb
index c07f748e99..c96486a452 100644
--- a/sample/drb/dchats.rb
+++ b/sample/drb/dchats.rb
@@ -2,7 +2,6 @@
distributed Ruby --- chat server
Copyright (c) 1999-2000 Masatoshi SEKI
=end
-require 'thread'
require 'drb/drb'
class ChatEntry
@@ -29,7 +28,7 @@ end
class ChatServer
def initialize
- @mutex = Mutex.new
+ @mutex = Thread::Mutex.new
@members = {}
end
diff --git a/sample/drb/dhasen.rb b/sample/drb/dhasen.rb
index 651b9c6c8a..13ff38940e 100644
--- a/sample/drb/dhasen.rb
+++ b/sample/drb/dhasen.rb
@@ -17,13 +17,12 @@
require 'drb/drb'
require 'chasen'
-require 'thread'
class Dhasen
include DRbUndumped
def initialize
- @mutex = Mutex.new
+ @mutex = Thread::Mutex.new
end
def sparse(str, *arg)
diff --git a/sample/drb/dlogd.rb b/sample/drb/dlogd.rb
index 42f302e64e..a87e660346 100644
--- a/sample/drb/dlogd.rb
+++ b/sample/drb/dlogd.rb
@@ -4,13 +4,12 @@
=end
require 'drb/drb'
-require 'thread'
class Logger
def initialize(fname)
@fname = fname.to_s
@fp = File.open(@fname, "a+")
- @queue = Queue.new
+ @queue = Thread::Queue.new
@th = Thread.new { self.flush }
end
diff --git a/sample/drb/dqueue.rb b/sample/drb/dqueue.rb
index 1c8878c080..a9afa8c858 100644
--- a/sample/drb/dqueue.rb
+++ b/sample/drb/dqueue.rb
@@ -3,10 +3,9 @@
Copyright (c) 1999-2000 Masatoshi SEKI
=end
-require 'thread'
require 'drb/drb'
-DRb.start_service(nil, Queue.new)
+DRb.start_service(nil, Thread::Queue.new)
puts DRb.uri
DRb.thread.join
diff --git a/sample/drb/http0serv.rb b/sample/drb/http0serv.rb
index 9503a1790c..2e853312e1 100644
--- a/sample/drb/http0serv.rb
+++ b/sample/drb/http0serv.rb
@@ -1,7 +1,6 @@
require 'webrick'
require 'drb/drb'
-require 'drb/http0'
-require 'thread'
+require_relative 'http0'
module DRb
module HTTP0
@@ -18,7 +17,7 @@ module DRb
def initialize(config, drb)
@config = config
@drb = drb
- @queue = Queue.new
+ @queue = Thread::Queue.new
end
def do_POST(req, res)
@@ -46,7 +45,7 @@ module DRb
def initialize(uri, config)
@uri = uri
@config = config
- @queue = Queue.new
+ @queue = Thread::Queue.new
setup_webrick(uri)
end
attr_reader :uri
@@ -62,7 +61,7 @@ module DRb
def accept
client = @queue.pop
- ServerSide.new(client, @config)
+ ServerSide.new(uri, client, @config)
end
def setup_webrick(uri)
@@ -80,12 +79,14 @@ module DRb
end
class ServerSide
- def initialize(callback, config)
+ def initialize(uri, callback, config)
+ @uri = uri
@callback = callback
@config = config
@msg = DRbMessage.new(@config)
@req_stream = StrStream.new(@callback.req_body)
end
+ attr_reader :uri
def close
@callback.close if @callback
diff --git a/sample/drb/name.rb b/sample/drb/name.rb
index 9527d47764..6d88186dab 100644
--- a/sample/drb/name.rb
+++ b/sample/drb/name.rb
@@ -35,16 +35,16 @@ How to play.
| 2
=end
-require 'thread.rb'
require 'drb/drb'
module DRbNamedObject
DRbNAMEDICT = {}
+ DRBNAMEMUTEX = Thread::Mutex.new
attr_reader(:drb_name)
def drb_name=(name)
@drb_name = name
- Thread.exclusive do
+ DRBNAMEMUTEX.synchronize do
raise(IndexError, name) if DRbNAMEDICT[name]
DRbNAMEDICT[name] = self
end
@@ -75,7 +75,7 @@ class Seq
def initialize(v, name)
@counter = v
- @mutex = Mutex.new
+ @mutex = Thread::Mutex.new
self.drb_name = name
end
@@ -90,7 +90,7 @@ end
class Front
def initialize
seq = Seq.new(0, 'seq')
- mutex = Mutex.new
+ mutex = Thread::Mutex.new
mutex.extend(DRbUndumped)
mutex.extend(DRbNamedObject)
mutex.drb_name = 'mutex'
diff --git a/sample/drb/old_tuplespace.rb b/sample/drb/old_tuplespace.rb
index 9c10a34527..2d5310086e 100644
--- a/sample/drb/old_tuplespace.rb
+++ b/sample/drb/old_tuplespace.rb
@@ -3,8 +3,6 @@
# Copyright (c) 1999-2000 Masatoshi SEKI
# You can redistribute it and/or modify it under the same terms as Ruby.
-require 'thread'
-
class TupleSpace
class Template
def initialize(list)
@@ -33,7 +31,7 @@ class TupleSpace
def initialize
@que = {}
@waiting = {}
- @que.taint # enable tainted comunication
+ @que.taint # enable tainted communication
@waiting.taint
self.taint
end
diff --git a/sample/drb/ring_echo.rb b/sample/drb/ring_echo.rb
index 3b743cab8e..c54628b54c 100644
--- a/sample/drb/ring_echo.rb
+++ b/sample/drb/ring_echo.rb
@@ -1,7 +1,6 @@
require 'drb/drb'
require 'drb/eq'
require 'rinda/ring'
-require 'thread'
class RingEcho
include DRbUndumped
diff --git a/sample/drb/simpletuple.rb b/sample/drb/simpletuple.rb
index bfbd86e665..4bb4b1cff9 100644
--- a/sample/drb/simpletuple.rb
+++ b/sample/drb/simpletuple.rb
@@ -3,8 +3,6 @@
# Copyright (c) 1999-2000 Masatoshi SEKI
# You can redistribute it and/or modify it under the same terms as Ruby.
-require 'thread'
-
class SimpleTupleSpace
def initialize
@hash = {}