mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
document a blocking behavior of IO#eof?.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
768e6c1328
commit
fe13de2096
1 changed files with 21 additions and 2 deletions
23
io.c
23
io.c
|
@ -908,12 +908,31 @@ io_getc(OpenFile *fptr)
|
|||
* 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
|
||||
|
|
Loading…
Add table
Reference in a new issue