diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | ext/io/nonblock/nonblock.c | 23 |
2 files changed, 29 insertions, 0 deletions
@@ -1,3 +1,9 @@ +Thu Oct 17 05:52:31 2013 Zachary Scott <e@zzak.io> + + * ext/io/nonblock/nonblock.c: [DOC] Document io/nonblock by reprah + [Fixes GH-418] https://github.com/ruby/ruby/pull/418 based on the + original discussion from documenting-ruby/ruby#18 + Thu Oct 17 05:40:33 2013 Koichi Sasada <ko1@atdot.net> * gc.c (objspace_each_objects): do not skip empty RVALUEs. diff --git a/ext/io/nonblock/nonblock.c b/ext/io/nonblock/nonblock.c index 8b3d842bad..ccd8728a31 100644 --- a/ext/io/nonblock/nonblock.c +++ b/ext/io/nonblock/nonblock.c @@ -30,6 +30,12 @@ io_nonblock_mode(int fd) #endif #ifdef F_GETFL +/* + * call-seq: + * io.nonblock? -> boolean + * + * Returns +true+ if an IO object is in non-blocking mode. + */ static VALUE rb_io_nonblock_p(VALUE io) { @@ -61,6 +67,13 @@ io_nonblock_set(int fd, int f, int nb) rb_sys_fail(0); } +/* + * call-seq: + * io.nonblock = boolean -> boolean + * + * Enables non-blocking mode on a stream when set to + * +true+, and blocking mode when set to +false+. + */ static VALUE rb_io_nonblock_set(VALUE io, VALUE nb) { @@ -79,6 +92,16 @@ io_nonblock_restore(VALUE arg) return Qnil; } +/* + * call-seq: + * io.nonblock {|io| } -> io + * io.nonblock(boolean) {|io| } -> io + * + * Yields +self+ in non-blocking mode. + * + * When +false+ is given as an argument, +self+ is yielded in blocking mode. + * The original mode is restored after the block is executed. + */ static VALUE rb_io_nonblock_block(int argc, VALUE *argv, VALUE io) { |