Class: DCell::RPC::Manager

Inherits:
Object
  • Object
show all
Defined in:
lib/dcell/rpc.rb

Overview

Tracks calls-in-flight

Class Method Summary collapse

Class Method Details

.claim(call_id) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/dcell/rpc.rb', line 53

def self.claim(call_id)
  @mutex.lock
  begin
    ref = @calls.delete(call_id)
    ref.__getobj__ if ref
  rescue WeakRef::RefError
    # Nothing to see here, folks
  ensure
    @mutex.unlock rescue nil
  end
end

.register(call) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/dcell/rpc.rb', line 37

def self.register(call)
  @mutex.lock
  begin
    call_id = @ids[call.object_id]
    unless call_id
      call_id = Celluloid.uuid
      @ids[call.object_id] = call_id
    end

    @calls[call_id] = WeakRef.new(call)
    call_id
  ensure
    @mutex.unlock rescue nil
  end
end