Method: IO#concurrently_read

Defined in:
lib/all/io.rb

#concurrently_read(maxlen) ⇒ String #concurrently_read(maxlen, outbuf) ⇒ outbuf

Reads from IO concurrently.

Reading is done in a concurrent evaluation in the background.

This method is a shortcut for:

concurrently{ io.await_read(maxlen, outbuf) }

Examples:

r,w = IO.pipe
w.write "Hello!"
r.concurrently_read 1024 # => "Hello!"

Overloads:

  • #concurrently_read(maxlen) ⇒ String

    Reads maxlen bytes from IO and returns it as new string

    Parameters:

    • maxlen (Integer)

    Returns:

    • (String)

      read string

  • #concurrently_read(maxlen, outbuf) ⇒ outbuf

    Reads maxlen bytes from IO and fills the given buffer with them.

    Parameters:

    • maxlen (Integer)
    • outbuf (String)

    Returns:

    • (outbuf)

      outbuf filled with read string

See Also:

Since:

  • 1.0.0



162
163
164
# File 'lib/all/io.rb', line 162

def concurrently_read(maxlen, outbuf = nil)
  READ_PROC.call_detached(self, maxlen, outbuf)
end