Class: Socket::HostnameResolutionResult
Relationships & Source Files | |
Inherits: | Object |
Defined in: | ext/socket/lib/socket.rb |
Class Method Summary
- .new(size) ⇒ HostnameResolutionResult constructor
Instance Method Summary
Constructor Details
.new(size) ⇒ HostnameResolutionResult
# File 'ext/socket/lib/socket.rb', line 1000
def initialize(size) @size = size @taken_count = 0 @rpipe, @wpipe = IO.pipe @results = [] @mutex = Mutex.new end
Instance Method Details
#add(family, result)
[ GitHub ]# File 'ext/socket/lib/socket.rb', line 1012
def add(family, result) @mutex.synchronize do @results.push [family, result] @wpipe.putc HOSTNAME_RESOLUTION_QUEUE_UPDATED end end
#close
[ GitHub ]# File 'ext/socket/lib/socket.rb', line 1034
def close @rpipe.close @wpipe.close end
#get
[ GitHub ]# File 'ext/socket/lib/socket.rb', line 1019
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
[ GitHub ]# File 'ext/socket/lib/socket.rb', line 1008
def notifier [@rpipe] end