Project

General

Profile

Bug #3728 » issue3728.patch

eitoball (Eito Katagiri), 09/24/2010 11:40 PM

View differences:

io.c
* IO.select(read_array
* [, write_array
* [, error_array
* [, timeout]]] )-> array or nil
* [, timeout]]]) -> array or nil
*
* See <code>Kernel#select</code>.
* Calls select(2) system call.
* It monitors given arrays of <code>IO</code> objects, waits one or more
* of <code>IO</code> objects ready for reading, are ready for writing,
* and have pending exceptions respectably, and returns an array that
* contains arrays of those IO objects. It will return <code>nil</code>
* if optional <i>timeout</i> value is given and no <code>IO</code> object
* is ready in <i>timeout</i> seconds.
*
* === Parameters
* read_array:: an array of <code>IO</code> objects that wait until ready for read
* write_array:: an array of <code>IO</code> objects that wait until ready for write
* error_array:: an array of <code>IO</code> objects that wait for exceptions
* timeout:: a numeric value in second
*
* === Example
*
* rp, wp = IO.pipe
* mesg = "ping "
* 100.times {
* rs, ws, = IO.select([rp], [wp])
* if r = rs[0]
* ret = r.read(5)
* print ret
* case ret
* when /ping/
* mesg = "pong\n"
* when /pong/
* mesg = "ping "
* end
* end
* if w = ws[0]
* w.write(mesg)
* end
* }
*
* <em>produces:</em>
*
* ping pong
* ping pong
* ping pong
* (snipped)
* ping
*/
static VALUE
rb_f_select(int argc, VALUE *argv, VALUE obj)
{
(2-2/2)