summaryrefslogtreecommitdiff
path: root/ext/io/nonblock
diff options
context:
space:
mode:
authorzzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-16 20:54:23 +0000
committerzzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-16 20:54:23 +0000
commit64afa78e8a471122accb4ffa6ff8ce74e3061e94 (patch)
tree6b8042c12ae8d5f81907ddef217e3c5e2e775f77 /ext/io/nonblock
parent82d06c5adeaa54e451e9f873d63b27e3e47f91db (diff)
* 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
Diffstat (limited to 'ext/io/nonblock')
-rw-r--r--ext/io/nonblock/nonblock.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/ext/io/nonblock/nonblock.c b/ext/io/nonblock/nonblock.c
index 8b3d842bad7..ccd8728a31b 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)
{