diff --git a/ChangeLog b/ChangeLog index ed54c9434c..9f288e45c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Oct 21 16:07:20 2010 NARUSE, Yui + + * io.c (rb_f_select): change rdoc. + patched by Eito Katagiri [ruby-core:31805] + Thu Oct 21 15:55:21 2010 NARUSE, Yui * lib/webrick/httpauth/digestauth.rb diff --git a/io.c b/io.c index 27c991834e..4b8d34ab29 100644 --- a/io.c +++ b/io.c @@ -7347,22 +7347,53 @@ select_end(VALUE arg) /* * call-seq: - * [IO.]select(read_array [, write_array [, error_array [, timeout ]]]) -> array | nil + * IO.select(read_array + * [, write_array + * [, error_array + * [, timeout]]]) -> array or nil * - * Performs a low-level select call, which waits for data - * to become available from input/output devices. The first three - * parameters are arrays of +IO+ objects or +nil+. The last is a - * timeout in seconds, which should be an +Integer+ or a +Float+. - * The call waits for data to become available for any of the +IO+ - * objects in _read_array_, for buffers to have cleared sufficiently to - * enable writing to any of the devices in _write_array_, or for an error - * to occur on the devices in _error_array_. If one or more of these - * conditions are met, the call returns a three-element array containing - * arrays of the +IO+ objects that were ready. Otherwise, if there is no - * change in status for _timeout_ seconds, the call returns +nil+. If all - * parameters are +nil+, the current thread sleeps forever. + * Calls select(2) system call. + * It monitors given arrays of IO objects, waits one or more + * of IO 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 nil + * if optional timeout value is given and no IO object + * is ready in timeout seconds. * - * select( [STDIN], nil, nil, 1.5 ) + * === Parameters + * read_array:: an array of IO objects that wait until ready for read + * write_array:: an array of IO objects that wait until ready for write + * error_array:: an array of IO 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 + * } + * + * produces: + * + * ping pong + * ping pong + * ping pong + * (snipped) + * ping */ static VALUE