Method: Rinda::RingFinger#lookup_ring_any

Defined in:
lib/rinda/ring.rb

#lookup_ring_any(timeout = 5) ⇒ Object

Returns the first found remote TupleSpace. Any further recovered TupleSpaces can be found by calling to_a.



390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
# File 'lib/rinda/ring.rb', line 390

def lookup_ring_any(timeout=5)
  queue = Thread::Queue.new

  Thread.new do
    self.lookup_ring(timeout) do |ts|
      queue.push(ts)
    end
    queue.push(nil)
  end

  @primary = queue.pop
  raise('RingNotFound') if @primary.nil?

  Thread.new do
    while it = queue.pop
      @rings.push(it)
    end
  end

  @primary
end