Class: Celluloid::CellProxy

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

Direct Known Subclasses

DCell::CellProxy

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

._load(string) ⇒ Object

Create an actor proxy object which routes messages over DCell’s overlay network and back to the original mailbox



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/dcell/celluloid_ext.rb', line 30

def self._load(string)
  mailbox = ::Celluloid::Mailbox._load(string)

  case mailbox
  when ::DCell::MailboxProxy
    actor = ::DCell::Actor.new(mailbox)
    ::DCell::CellProxy.new actor.proxy, mailbox, actor.subject.class.to_s
  when ::Celluloid::Mailbox
    actor = find_actor(mailbox)
    ::Celluloid::CellProxy.new actor.proxy, mailbox, actor.behavior.subject.class.to_s
  else
    ::Kernel.raise "funny, I did not expect to see a #{mailbox.class} here"
  end
end

.find_actor(mailbox) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/dcell/celluloid_ext.rb', line 45

def self.find_actor(mailbox)
  ::Thread.list.each do |t|
    if actor = t[:celluloid_actor]
      return actor if actor.mailbox == mailbox
    end
  end
  ::Kernel.raise "no actor found for mailbox: #{mailbox.inspect}"
end

Instance Method Details

#__respond_to?Object

Marshal uses respond_to? to determine if this object supports _dump so unfortunately we have to monkeypatch in _dump support as the proxy itself normally jacks respond_to? and proxies to the actor



16
# File 'lib/dcell/celluloid_ext.rb', line 16

alias_method :__respond_to?, :respond_to?

#_dump(level) ⇒ Object

Dump an actor proxy via its mailbox



24
25
26
# File 'lib/dcell/celluloid_ext.rb', line 24

def _dump(level)
  @mailbox._dump(level)
end

#respond_to?(meth, check_private = false) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
# File 'lib/dcell/celluloid_ext.rb', line 17

def respond_to?(meth, check_private = false)
  return false if meth == :marshal_dump
  return true  if meth == :_dump
  __respond_to?(meth, check_private)
end