Sha256: 7f83fd92345ec0484da8dac6794760b18d3a96832b5571fd912973fc699fe179

Contents?: true

Size: 977 Bytes

Versions: 12

Compression:

Stored size: 977 Bytes

Contents

require 'drb/drb'
require 'rinda/rinda'

Thread.abort_on_exception = true

module DRb
  class DRbConn
    @table = {}
    def self.open(remote_uri)  # :nodoc:
      begin
        conn = nil

        @mutex.synchronize do
          cache = @table[remote_uri]
          if not(cache.nil?) && cache.alive?
            conn = cache
          else
            puts "new"
            cache.close unless cache.nil?
            conn = self.new(remote_uri) unless conn
            @table[remote_uri] = conn
          end
        end

        succ, result = yield(conn)
        return succ, result

      ensure
        if conn
          if succ
            puts "succ"
          else
            conn.close
          end
        end
      end
    end
  end
end

DRb.start_service

ts = DRbObject.new_with_uri('druby://localhost:30000')
$count = 0
10000.times do
  Thread.new do
    $count += 1
    ts.take([:a])
  end
end

loop do
  break if $count == 10000
  puts $count
  sleep 1
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
pione-0.4.0 misc/test-many-waiters-client.rb
pione-0.3.2 misc/test-many-waiters-client.rb
pione-0.3.1 misc/test-many-waiters-client.rb
pione-0.3.0 misc/test-many-waiters-client.rb
pione-0.2.2 misc/test-many-waiters-client.rb
pione-0.2.1 misc/test-many-waiters-client.rb
pione-0.2.0 misc/test-many-waiters-client.rb
pione-0.1.4 misc/test-many-waiters-client.rb
pione-0.1.3 misc/test-many-waiters-client.rb
pione-0.1.2 misc/test-many-waiters-client.rb
pione-0.1.1 misc/test-many-waiters-client.rb
pione-0.1.0 misc/test-many-waiters-client.rb