class IORequest::Utility::ExtendedID
Extended Id of object
Attributes
oid[R]
@return [Integer] object ID.
pid[R]
@return [Integer] process ID.
tid[R]
@return [Integer] thread ID.
Public Class Methods
from(obj)
click to toggle source
# File lib/io_request/utility/with_id.rb, line 42 def self.from(obj) case obj when ExtendedID then new(obj.pid, obj.tid, obj.oid) when String then new(*obj.split('#').map(&:to_i)) else raise 'unknown type' end end
new(pid = nil, tid = nil, oid = nil)
click to toggle source
Create new Id based on PID, thread ID and object ID.
# File lib/io_request/utility/with_id.rb, line 11 def initialize(pid = nil, tid = nil, oid = nil) @pid = pid || Process.pid @tid = tid || Thread.current.object_id @oid = oid || object_id end
Public Instance Methods
<=>(other)
click to toggle source
Comparison operator.
# File lib/io_request/utility/with_id.rb, line 32 def <=>(other) if @pid == other.pid && @tid == other.tid @oid <=> other.oid elsif @pid == other.pid && @tid != other.tid @tid <=> tid else @pid <=> other.pid end end
to_s()
click to toggle source
@return [String]
# File lib/io_request/utility/with_id.rb, line 27 def to_s "#{@pid}##{@tid}##{@oid}" end