From: Robert Klemme Date: 2003-03-08T00:36:00+09:00 Subject: Re: DRB and threads "Brian Candler" schrieb im Newsbeitrag news:20030307131203.B99950@linnet.org... > > Yes, that's correct. Since the server can hand the instance's reference to > > multiple clients (or a single multithreaded client) you must take measures > > to handle this. > > OK, that's good to know; it could probably do with making clear in the > documentation, since Bad Things will likely happen if you take an arbitrary > object (like a DBI::DatabaseHandle) and share it via DRb! Yes. > I did find references to a pool in the source (Class DRbConn), however it > looks like it's for a client to have a pool of connections to multiple > remote URIs, rather than a server having a pool of objects to handle > requests. Like: require 'thread' class Pool def initialize(type, *args) @mutex = Mutex.new @type = type @args = args @pool = [] end def get @mutex.synchronize do @pool.shift or createNew() end end def put(elem) @mutex.synchronize do @pool.push elem end end def createNew @type.new(*@args) end end > I was thinking along the same lines. I guess it shouldn't be too hard to > code, but it's unusual in Ruby to find something generic like this not > already implemented :-) Well, there's always room to contribute something new, I guess. regards robert