Class: EMRPC::RemotePid

Inherits:
Object show all
Includes:
Pid
Defined in:
lib/emrpc/evented_api/remote_pid.rb

Overview

RemotePid is an interface for the actual remote pid.

Constant Summary

Constants included from ProtocolMapper

ProtocolMapper::MAP

Instance Attribute Summary collapse

Attributes included from Pid

#_bind_address, #_em_server_signature, #_protocol, #connections, #killed, #options, #uuid

Instance Method Summary collapse

Methods included from Pid

#==, #_send_dirty, #_uid, #bind, #connect, #connection_established, #connection_unbind, #connection_uuids, #disconnect, #encode_b381b571_1ab2_5889_8221_855dbbc76242, #find_pid, #killed?, #marshal_dump, #marshal_load, new, #pid_class_name, #spawn, #tcp_spawn, #thread_spawn

Methods included from DebugPidCallbacks

#_debug, #connected, #connection_failed, #disconnected, #handshake_failed, #on_raise, #on_return

Methods included from ProtocolMapper

#make_client_connection, #make_server_connection, register_protocol

Methods included from DefaultCallbacks

#connected, #connection_failed, #disconnected, #handshake_failed, #on_raise, #on_return

Constructor Details

#initialize(conn, options) ⇒ RemotePid

Returns a new instance of RemotePid.



7
8
9
10
11
12
# File 'lib/emrpc/evented_api/remote_pid.rb', line 7

def initialize(conn, options)
  _common_init
  @_connection = conn
  @uuid        = options[:uuid]
  @options     = options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object



14
15
16
# File 'lib/emrpc/evented_api/remote_pid.rb', line 14

def method_missing(*args)
  send(*args)
end

Instance Attribute Details

#_connectionObject

Returns the value of attribute _connection.



5
6
7
# File 'lib/emrpc/evented_api/remote_pid.rb', line 5

def _connection
  @_connection
end

Instance Method Details

#inspectObject



32
33
34
35
# File 'lib/emrpc/evented_api/remote_pid.rb', line 32

def inspect
  return "#<RemotePid:#{_uid} KILLED>" if @killed
  "#<RemotePid:#{_uid} on #{@_connection.address} connected with local pid #{@_connection.local_pid._uid}>"
end

#killObject



28
29
30
# File 'lib/emrpc/evented_api/remote_pid.rb', line 28

def kill
  send(:kill)
end

#send(*args) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/emrpc/evented_api/remote_pid.rb', line 18

def send(*args)
  cmd = args.first
  if cmd == :kill
    return if @killed
    @killed = true
    @_connection.close_connection_after_writing
  end
  @_connection.send_raw_message(args)
end