module Gio::PollableInputStream
Public Instance Methods
create_source(&block)
click to toggle source
# File lib/gio2/pollable-input-stream.rb, line 20 def create_source(&block) source = create_source_raw source.extend(PollableSource) source.set_callback(&block) source end
Also aliased as: create_source_raw
read_nonblocking(size=nil)
click to toggle source
# File lib/gio2/pollable-input-stream.rb, line 28 def read_nonblocking(size=nil) if size.nil? all = "".b buffer_size = 8192 buffer = " ".b * buffer_size loop do begin read_bytes = read_nonblocking_raw_compatible(buffer) rescue IOError::WouldBlock break end all << buffer.byteslice(0, read_bytes) break if read_bytes != buffer_size end all else buffer = " ".b * size read_bytes = read_nonblocking_raw_compatible(buffer) buffer.replace(buffer.byteslice(0, read_bytes)) buffer end end
Also aliased as: read_nonblocking_raw
Private Instance Methods
read_nonblocking_raw_compatible(buffer)
click to toggle source
# File lib/gio2/pollable-input-stream.rb, line 52 def read_nonblocking_raw_compatible(buffer) if (GLib::VERSION <=> [2, 42, 0]) >= 0 n_bytes, = read_nonblocking_raw(buffer) n_bytes else read_nonblocking_raw(buffer, buffer.bytesize) end end