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



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

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

.register(call) ⇒ Object



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

def self.register(call)
  @mutex.lock
  call_id = @ids[call.object_id]
  unless call_id
    call_id = @serial
    @serial += 1
    @ids[call.object_id] = call_id
  end

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