Ruby  1.9.3p429(2013-05-15revision40747)
wait_for_single_fd.c
Go to the documentation of this file.
1 #include "ruby/ruby.h"
2 #include "ruby/io.h"
3 
4 static VALUE
5 wait_for_single_fd(VALUE ign, VALUE fd, VALUE events, VALUE timeout)
6 {
7  struct timeval tv;
8  struct timeval *tvp = NULL;
9  int rc;
10 
11  if (!NIL_P(timeout)) {
12  tv = rb_time_timeval(timeout);
13  tvp = &tv;
14  }
15 
16  rc = rb_wait_for_single_fd(NUM2INT(fd), NUM2INT(events), tvp);
17  if (rc == -1)
18  rb_sys_fail("rb_wait_for_single_fd");
19  return INT2NUM(rc);
20 }
21 
22 void
24 {
26  rb_define_const(rb_cObject, "RB_WAITFD_OUT", INT2NUM(RB_WAITFD_OUT));
27  rb_define_const(rb_cObject, "RB_WAITFD_PRI", INT2NUM(RB_WAITFD_PRI));
28  rb_define_singleton_method(rb_cIO, "wait_for_single_fd",
30 }
31