lib/polyphony/extensions/io.rb in polyphony-0.59.1 vs lib/polyphony/extensions/io.rb in polyphony-0.60
- old
+ new
@@ -99,30 +99,30 @@
alias_method :orig_getc, :getc
def getc
return @read_buffer.slice!(0) if @read_buffer && !@read_buffer.empty?
@read_buffer ||= +''
- Polyphony.backend_read(self, @read_buffer, 8192, false)
+ Polyphony.backend_read(self, @read_buffer, 8192, false, -1)
return @read_buffer.slice!(0) if !@read_buffer.empty?
nil
end
alias_method :orig_read, :read
def read(len = nil)
@read_buffer ||= +''
- result = Polyphony.backend_read(self, @read_buffer, len, true)
+ result = Polyphony.backend_read(self, @read_buffer, len, true, -1)
return nil unless result
already_read = @read_buffer
@read_buffer = +''
already_read
end
alias_method :orig_readpartial, :read
- def readpartial(len, str = +'')
- result = Polyphony.backend_read(self, str, len, false)
+ def readpartial(len, str = +'', buffer_pos = 0)
+ result = Polyphony.backend_read(self, str, len, false, buffer_pos)
raise EOFError unless result
result
end
@@ -149,13 +149,14 @@
while true
idx = @read_buffer.index(sep)
return @read_buffer.slice!(0, idx + sep_size) if idx
- data = readpartial(8192, +'')
- return nil unless data
- @read_buffer << data
+ result = readpartial(8192, @read_buffer, -1)
+
+ #Polyphony.backend_read(self, @read_buffer, 8192, false, -1)
+ return nil unless result
end
rescue EOFError
return nil
end
@@ -214,11 +215,11 @@
alias_method :orig_read_nonblock, :read_nonblock
def read_nonblock(maxlen, buf = nil, _options = nil)
buf ? readpartial(maxlen, buf) : readpartial(maxlen)
end
- def read_loop(&block)
- Polyphony.backend_read_loop(self, &block)
+ def read_loop(maxlen = 8192, &block)
+ Polyphony.backend_read_loop(self, maxlen, &block)
end
def feed_loop(receiver, method = :call, &block)
Polyphony.backend_feed_loop(self, receiver, method, &block)
end