int rb_thread_select(int max, fd_set * read, fd_set * write, fd_set * except, struct timeval *timeout) { if (!read && !write && !except) { if (!timeout) { rb_thread_sleep_forever(); return 0; } rb_thread_wait_for(*timeout); return 0; } else { return do_select(max, read, write, except, timeout); } }
static VALUE mutex_sleep(VALUE self, SEL sel, int argc, VALUE *argv) { VALUE timeout; rb_scan_args(argc, argv, "01", &timeout); rb_mutex_unlock(self, 0); time_t beg, end; beg = time(0); if (timeout == Qnil) { rb_thread_sleep_forever(); } else { struct timeval t = rb_time_interval(timeout); rb_thread_wait_for(t); } end = time(0) - beg; return INT2FIX(end); }
static VALUE rb_thread_stop(VALUE rcv, SEL sel) { rb_thread_sleep_forever(); return Qnil; }
static VALUE thread_sleep_forever(VALUE time) { rb_thread_sleep_forever(); return Qnil; }