From 64afa78e8a471122accb4ffa6ff8ce74e3061e94 Mon Sep 17 00:00:00 2001 From: zzak Date: Wed, 16 Oct 2013 20:54:23 +0000 Subject: * 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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43314 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/io/nonblock/nonblock.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'ext/io/nonblock/nonblock.c') 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) { -- cgit v1.2.3