/*
 * call-seq:
 *
 *      io.kgio_wait_writable           -> IO
 *      io.kgio_wait_writable(timeout)  -> IO or nil
 *
 * Blocks the running Thread indefinitely until the IO object is writable
 * or if +timeout+ expires.  If +timeout+ is specified and expires, +nil+
 * is returned.
 *
 * This method is automatically called (without timeout argument) by default
 * whenever kgio_write needs to block on output.
 *
 * Users of alternative threading/fiber libraries are
 * encouraged to override this method in their subclasses or modules to
 * work with their threading/blocking methods.
 */
static VALUE kgio_wait_writable(int argc, VALUE *argv, VALUE self)
{
        int r = kgio_wait(argc, argv, self, 1);

        if (r < 0) rb_sys_fail("kgio_wait_writable");
        return r == 0 ? Qnil : self;
}