class Async::IO
Represents an asynchronous IO within a reactor.
def self.[] instance
def self.[] instance WRAPPERS[instance.class] end
def async
def async while true begin result = yield case result when :wait_readable wait_readable when :wait_writable wait_writable else return result end rescue ::IO::WaitReadable wait_readable rescue ::IO::WaitWritable wait_writable end end end
def async_send(*args)
def async_send(*args) async do @io.__send__(*args, exception: false) end end
def async_send(*args)
def async_send(*args) async do @io.__send__(*args) end end
def wrap_blocking_method(new_name, method_name, &block)
@method $1
@!macro [attach] wrap_blocking_method
def wrap_blocking_method(new_name, method_name, &block) if block_given? define_method(new_name, &block) else define_method(new_name) do |*args| async_send(method_name, *args) end end end
def wraps(klass, *additional_methods)
def wraps(klass, *additional_methods) WRAPPERS[klass] = self # klass.instance_methods(false).grep(/(.*)_nonblock/) do |method_name| # wrap_blocking_method($1, method_name) # end def_delegators :@io, *(additional_methods - instance_methods(false)) end