Project

General

Profile

Actions

Feature #5138

closed

Add nonblocking IO that does not use exceptions for EOF and EWOULDBLOCK

Added by wycats (Yehuda Katz) over 12 years ago. Updated almost 10 years ago.

Status:
Closed
Target version:
[ruby-core:38666]

Description

The current Ruby I/O classes have non-blocking methods (read_nonblock and write_nonblock). These methods will never block, and if they would block, they raise an exception instead (IO::WaitReadable or IO::WaitWritable). In addition, if the IO is at EOF, they raise an EOFError.

These exceptions are raised repeatedly in virtually every use of the non-blocking methods. This patch adds a pair of methods (try_read_nonblock and try_write_nonblock) that have the same semantics as the existing methods, but they return Symbols instead of raising exceptions for these routine cases:

  • :read_would_block
  • :write_would_block
  • :eof

The patch contains updates for IO, StringIO, and OpenSSL. The updates are fully documented and tested.


Files

try_nonblock.diff (19.8 KB) try_nonblock.diff wycats (Yehuda Katz), 08/02/2011 07:35 AM
try_nonblock.diff (20.3 KB) try_nonblock.diff wycats (Yehuda Katz), 08/02/2011 09:02 AM
try_nonblock.diff (20.2 KB) try_nonblock.diff wycats (Yehuda Katz), 08/02/2011 01:01 PM
noname (500 Bytes) noname tenderlovemaking (Aaron Patterson), 08/04/2011 02:59 AM
noname (500 Bytes) noname Anonymous, 11/20/2011 02:23 PM
feature5138.pdf (38.2 KB) feature5138.pdf tenderlovemaking (Aaron Patterson), 07/01/2012 04:34 AM
noname (500 Bytes) noname Anonymous, 07/01/2012 04:53 AM
nonblock_no_tuple.patch (20.3 KB) nonblock_no_tuple.patch nonblock without a tuple tenderlovemaking (Aaron Patterson), 07/10/2013 06:24 AM
nonblock_tuple.patch (21.9 KB) nonblock_tuple.patch nonblock with a tuple tenderlovemaking (Aaron Patterson), 07/10/2013 06:24 AM

Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #4560: [PATCH] lib/net/protocol.rb: avoid exceptions in rbuf_fillClosednormalperson (Eric Wong)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0