diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-09-05 15:02:10 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-09-05 15:02:10 +0000 |
commit | 3a1db0a247488a9b6c27c2591527da92238298b8 (patch) | |
tree | 5defe186fded06b9d17a24d887e9147c1d227119 | |
parent | b5692b33ec31417b2c40cc6b9e418185410a6c3c (diff) | |
download | ruby-3a1db0a247488a9b6c27c2591527da92238298b8.tar.gz ruby-3a1db0a247488a9b6c27c2591527da92238298b8.tar.xz ruby-3a1db0a247488a9b6c27c2591527da92238298b8.zip |
document a blocking behavior of IO#eof?.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@9084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | io.c | 27 |
1 files changed, 23 insertions, 4 deletions
@@ -755,13 +755,32 @@ rb_io_rewind(io) * call-seq: * ios.eof => true or false * ios.eof? => true or false - * - * Returns true if <em>ios</em> is at end of file. The stream must be - * opened for reading or an <code>IOError</code> will be raised. - * + * + * Returns true if <em>ios</em> is at end of file that means + * there are no more data to read. + * The stream must be opened for reading or an <code>IOError</code> will be + * raised. + * * f = File.new("testfile") * dummy = f.readlines * f.eof #=> true + * + * If <em>ios</em> is a stream such as pipe or socket, <code>IO#eof?</code> + * blocks until the other end sends some data or closes it. + * + * r, w = IO.pipe + * Thread.new { sleep 1; w.close } + * r.eof? #=> true after 1 second blocking + * + * r, w = IO.pipe + * Thread.new { sleep 1; w.puts "a" } + * r.eof? #=> false after 1 second blocking + * + * r, w = IO.pipe + * r.eof? # blocks forever + * + * Note that <code>IO#eof?</code> reads data to a input buffer. + * So <code>IO#sysread</code> doesn't work with <code>IO#eof?</code>. */ VALUE |