--3MwIy2ne0vdjdPXF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Aug 02, 2011 at 07:35:15AM +0900, Yehuda Katz wrote: >=20 > Issue #5138 has been reported by Yehuda Katz. >=20 > ---------------------------------------- > Bug #5138: Add nonblocking IO that does not use exceptions for EOF and EW= OULDBLOCK > http://redmine.ruby-lang.org/issues/5138 >=20 > Author: Yehuda Katz > Status: Open > Priority: Normal > Assignee: Yukihiro Matsumoto > Category: core > Target version: 1.9.4 > ruby -v: ruby 1.9.4dev (2011-07-31 trunk 32788) [x86_64-darwin11.0.0] >=20 >=20 > 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. >=20 > 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, b= ut they return Symbols instead of raising exceptions for these routine case= s: >=20 > * :read_would_block > * :write_would_block > * :eof >=20 > The patch contains updates for IO, StringIO, and OpenSSL. The updates are= fully documented and tested. This seems very handy for read loops. Always rescuing the exception bothered me. I think this would be very good functionality when writing pure ruby servers. --=20 Aaron Patterson http://tenderlovemaking.com/ --3MwIy2ne0vdjdPXF Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) iQEcBAEBAgAGBQJONyzBAAoJEJUxcLy0/6/GXlcH/1TxN6NMJqbSeLA0HzVfkhYs cXfYUbGHdRElnR9DrREFrURw6Na8qpc/4KNwUf1llMYZkv8NWgMZ7saAbReFfm5d 0ieDAIx3749zu61YluN28YkgnfqKaFxluzSSWgJ8PteWZ1A5A6NJ0J6e6GdSrNvz Lv4hVOC3a9C1XVhw2iG8E6M1QGfsMi1sTuq5cykg27pe+azEk3QjzRa/ljYlzHzX /dqSo3donFJ4gPrV0NhB/V1S1TN2j06/H8W8pstvCBfmOeaCsqTZzDrtmU4RwTNZ 04rvGyRm4PUU/BNLchGZhg7Zpn/cCibdKR4UChsx4FFzEAGZBYYvhy+V803GkSw= =YznE -----END PGP SIGNATURE----- --3MwIy2ne0vdjdPXF-- On Tue, Aug 02, 2011 at 07:35:15AM +0900, Yehuda Katz wrote: >=20 > Issue #5138 has been reported by Yehuda Katz. >=20 > ---------------------------------------- > Bug #5138: Add nonblocking IO that does not use exceptions for EOF and EW= OULDBLOCK > http://redmine.ruby-lang.org/issues/5138 >=20 > Author: Yehuda Katz > Status: Open > Priority: Normal > Assignee: Yukihiro Matsumoto > Category: core > Target version: 1.9.4 > ruby -v: ruby 1.9.4dev (2011-07-31 trunk 32788) [x86_64-darwin11.0.0] >=20 >=20 > 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. >=20 > 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, b= ut they return Symbols instead of raising exceptions for these routine case= s: >=20 > * :read_would_block > * :write_would_block > * :eof >=20 > The patch contains updates for IO, StringIO, and OpenSSL. The updates are= fully documented and tested. This seems very handy for read loops. Always rescuing the exception bothered me. I think this would be very good functionality when writing pure ruby servers. --=20 Aaron Patterson http://tenderlovemaking.com/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) iQEcBAEBAgAGBQJONyzBAAoJEJUxcLy0/6/GXlcH/1TxN6NMJqbSeLA0HzVfkhYs cXfYUbGHdRElnR9DrREFrURw6Na8qpc/4KNwUf1llMYZkv8NWgMZ7saAbReFfm5d 0ieDAIx3749zu61YluN28YkgnfqKaFxluzSSWgJ8PteWZ1A5A6NJ0J6e6GdSrNvz Lv4hVOC3a9C1XVhw2iG8E6M1QGfsMi1sTuq5cykg27pe+azEk3QjzRa/ljYlzHzX /dqSo3donFJ4gPrV0NhB/V1S1TN2j06/H8W8pstvCBfmOeaCsqTZzDrtmU4RwTNZ 04rvGyRm4PUU/BNLchGZhg7Zpn/cCibdKR4UChsx4FFzEAGZBYYvhy+V803GkSw= =YznE -----END PGP SIGNATURE-----