Spec-Zone.ru › Ruby 3.4

класс Socket::HostnameResolutionResult

Родитель:
Объект

Публичные Классовые Методы

new (size)
Исходный код
# File ext/socket/lib/socket.rb, line 979
def initialize(size)
  @size = size
  @taken_count = 0
  @rpipe, @wpipe = IO.pipe
  @results = []
  @mutex = Mutex.new
end

Публичные Экземплярные Методы

add (family, result)
Исходный код
# File ext/socket/lib/socket.rb, line 991
def add(family, result)
  @mutex.synchronize do
    @results.push [family, result]
    @wpipe.putc HOSTNAME_RESOLUTION_QUEUE_UPDATED
  end
end
close ()
Исходный код
# File ext/socket/lib/socket.rb, line 1013
def close
  @rpipe.close
  @wpipe.close
end
get ()
Исходный код
# File ext/socket/lib/socket.rb, line 998
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 ()
Исходный код
# File ext/socket/lib/socket.rb, line 987
def notifier
  [@rpipe]
end

Ruby Core © 1993–2024 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API