class Socket::HostnameResolutionResult

Public Class Methods

new(size) click to toggle source
# File socket/lib/socket.rb, line 998
def initialize(size)
  @size = size
  @taken_count = 0
  @rpipe, @wpipe = IO.pipe
  @results = []
  @mutex = Mutex.new
end

Public Instance Methods

add(family, result) click to toggle source
# File socket/lib/socket.rb, line 1010
def add(family, result)
  @mutex.synchronize do
    @results.push [family, result]
    @wpipe.putc HOSTNAME_RESOLUTION_QUEUE_UPDATED
  end
end
close() click to toggle source
# File socket/lib/socket.rb, line 1032
def close
  @rpipe.close
  @wpipe.close
end
get() click to toggle source
# File socket/lib/socket.rb, line 1017
def get
  return nil if @results.empty?

  res = nil

  @mutex.synchronize do
    @rpipe.getbyte
    res = @results.shift
  end

  @taken_count += 1
  close if @taken_count == @size
  res
end
notifier() click to toggle source
# File socket/lib/socket.rb, line 1006
def notifier
  [@rpipe]
end