| 1 |
#include "ruby/ruby.h" |
| 2 |
|
| 3 |
static VALUE |
| 4 |
thread_fd_close(VALUE ign, VALUE fd) |
| 5 |
{ |
| 6 |
rb_thread_fd_close(NUM2INT(fd)); |
| 7 |
return Qnil; |
| 8 |
} |
| 9 |
|
| 10 |
static VALUE |
| 11 |
thread_fd_wait(VALUE ign, VALUE fd) |
| 12 |
{ |
| 13 |
int ret = rb_thread_wait_fd(NUM2INT(fd)); |
| 14 |
return INT2NUM(ret); |
| 15 |
} |
| 16 |
|
| 17 |
static VALUE |
| 18 |
thread_fd_writable(VALUE ign, VALUE fd) |
| 19 |
{ |
| 20 |
int ret = rb_thread_fd_writable(NUM2INT(fd)); |
| 21 |
return INT2NUM(ret); |
| 22 |
} |
| 23 |
|
| 24 |
void |
| 25 |
Init_thread_fd(void) |
| 26 |
{ |
| 27 |
rb_define_singleton_method(rb_cIO, "thread_fd_close", thread_fd_close, 1); |
| 28 |
rb_define_singleton_method(rb_cIO, "thread_fd_wait", thread_fd_wait, 1); |
| 29 |
rb_define_singleton_method(rb_cIO, "thread_fd_writable", thread_fd_writable, 1); |
| 30 |
} |