Class Methods
::
ext/socket/lib/socket.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/ext/socket/lib/socket.rb, line 1049
def initialize(size)
@size = size
@taken_count = 0
@rpipe, @wpipe = IO.pipe
@queue = Queue.new
@mutex = Mutex.new
end
No documentation available
Instance Methods
ext/socket/lib/socket.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/ext/socket/lib/socket.rb, line 1068
def add_error(family, error)
@mutex.synchronize do
@queue.push [family, error]
@wpipe.putc HOSTNAME_RESOLUTION_QUEUE_UPDATED
end
end
No documentation available
ext/socket/lib/socket.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/ext/socket/lib/socket.rb, line 1061
def add_resolved(family, resolved_addrinfos)
@mutex.synchronize do
@queue.push [family, resolved_addrinfos]
@wpipe.putc HOSTNAME_RESOLUTION_QUEUE_UPDATED
end
end
No documentation available
ext/socket/lib/socket.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/ext/socket/lib/socket.rb, line 1098
def close_all
@queue.close unless @queue.closed?
@rpipe.close unless @rpipe.closed?
@wpipe.close unless @wpipe.closed?
end
No documentation available
#
ext/socket/lib/socket.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/ext/socket/lib/socket.rb, line 1090
def closed?
@rpipe.closed?
end
No documentation available
#
ext/socket/lib/socket.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/ext/socket/lib/socket.rb, line 1075
def get
return nil if @queue.empty?
res = nil
@mutex.synchronize do
@rpipe.getbyte
res = @queue.pop
end
@taken_count += 1
close_all if @taken_count == @size
res
end
No documentation available
#
ext/socket/lib/socket.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/ext/socket/lib/socket.rb, line 1094
def opened?
!closed?
end
No documentation available
ext/socket/lib/socket.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/ext/socket/lib/socket.rb, line 1057
def waiting_pipe
[@rpipe]
end
No documentation available