class Erlang::ETF::Pid
| 1 | N | 4 | 4 | 1 | | — | —- | — | —— | ——– | | 103 | Node | ID | Serial | Creation |
Encode a process identifier object (obtained from [`spawn/3`] or friends). The `ID` and `Creation` fields works just like in [`REFERENCE_EXT`], while the `Serial` field is used to improve safety. In `ID`, only 15 bits are significant; the rest should be 0.
(see [`PID_EXT`])
[`spawn/3`]: erlang.org/doc/man/erlang.html#spawn-3 [`REFERENCE_EXT`]: erlang.org/doc/apps/erts/erl_ext_dist.html#REFERENCE_EXT [`PID_EXT`]: erlang.org/doc/apps/erts/erl_ext_dist.html#PID_EXT
Constants
- HEAD
- UINT32BE
- UINT8
Public Class Methods
[](term, node = nil, id = nil, serial = nil, creation = nil)
click to toggle source
# File lib/erlang/etf/pid.rb, line 28 def [](term, node = nil, id = nil, serial = nil, creation = nil) return new(term, node, id, serial, creation) end
erlang_load(buffer)
click to toggle source
# File lib/erlang/etf/pid.rb, line 32 def erlang_load(buffer) node = Erlang::ETF.read_term(buffer) id, serial, creation = buffer.read(9).unpack(HEAD) term = Erlang::Pid[Erlang.from(node), Erlang.from(id), Erlang.from(serial), Erlang.from(creation)] return new(term, node, id, serial, creation) end
new(term, node = nil, id = nil, serial = nil, creation = nil)
click to toggle source
# File lib/erlang/etf/pid.rb, line 40 def initialize(term, node = nil, id = nil, serial = nil, creation = nil) raise ArgumentError, "term must be of type Erlang::Pid" if not term.kind_of?(Erlang::Pid) @term = term @node = node @id = id @serial = serial @creation = creation end
Public Instance Methods
erlang_dump(buffer = ::String.new.force_encoding(BINARY_ENCODING))
click to toggle source
# File lib/erlang/etf/pid.rb, line 49 def erlang_dump(buffer = ::String.new.force_encoding(BINARY_ENCODING)) buffer << PID_EXT Erlang::ETF.write_term(@node || @term.node, buffer) buffer << [ @id || @term.id, @serial || @term.serial, @creation || @term.creation ].pack(HEAD) return buffer end
inspect()
click to toggle source
Calls superclass method
Erlang::ETF::Term#inspect
# File lib/erlang/etf/pid.rb, line 60 def inspect if @node.nil? and @id.nil? and @serial.nil? and @creation.nil? return super else return "#{self.class}[#{@term.inspect}, #{@node.inspect}, #{@id.inspect}, #{@serial.inspect}, #{@creation.inspect}]" end end
pretty_print(pp)
click to toggle source
# File lib/erlang/etf/pid.rb, line 68 def pretty_print(pp) state = [@term] state.push(@node, @id, @serial, @creation) if not @node.nil? or not @id.nil? or not @serial.nil? or not @creation.nil? return pp.group(1, "#{self.class}[", "]") do pp.breakable '' pp.seplist(state) { |obj| obj.pretty_print(pp) } end end