Method: IO#wait_readable

Defined in:
wait/wait.c

#waittrue? #wait(timeout) ⇒ true? #wait_readabletrue? #wait_readable(timeout) ⇒ true?

Waits until IO is readable without blocking and returns self, or nil when times out. Returns true immediately when buffered data is available.

Overloads:

  • #waittrue?

    Returns:

    • (true, nil)
  • #wait(timeout) ⇒ true?

    Returns:

    • (true, nil)
  • #wait_readabletrue?

    Returns:

    • (true, nil)
  • #wait_readable(timeout) ⇒ true?

    Returns:

    • (true, nil)


130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'wait/wait.c', line 130

static VALUE
io_wait_readable(int argc, VALUE *argv, VALUE io)
{
    rb_io_t *fptr;
    struct timeval timerec;
    struct timeval *tv;

    GetOpenFile(io, fptr);
    rb_io_check_readable(fptr);
    tv = get_timeout(argc, argv, &timerec);
    if (rb_io_read_pending(fptr)) return Qtrue;
    if (wait_for_single_fd(fptr, RB_WAITFD_IN, tv)) {
	return io;
    }
    return Qnil;
}