Rework console to use rb_io_wait
.
This commit is contained in:
parent
8eea66a0ca
commit
7fca274198
Notes:
git
2020-09-14 13:44:35 +09:00
@ -513,22 +513,22 @@ console_getch(int argc, VALUE *argv, VALUE io)
|
|||||||
int w, len;
|
int w, len;
|
||||||
char buf[8];
|
char buf[8];
|
||||||
wint_t wbuf[2];
|
wint_t wbuf[2];
|
||||||
struct timeval *to = NULL, tv;
|
VALUE timeout = Qnil;
|
||||||
|
|
||||||
GetOpenFile(io, fptr);
|
GetOpenFile(io, fptr);
|
||||||
if (optp) {
|
if (optp) {
|
||||||
if (optp->vtime) {
|
if (optp->vtime) {
|
||||||
to = &tv;
|
struct timeval tv;
|
||||||
tv.tv_sec = optp->vtime / 10;
|
tv.tv_sec = optp->vtime / 10;
|
||||||
tv.tv_usec = (optp->vtime % 10) * 100000;
|
tv.tv_usec = (optp->vtime % 10) * 100000;
|
||||||
|
timeout = rb_scheduler_timeout(&tv);
|
||||||
}
|
}
|
||||||
if (optp->vmin != 1) {
|
if (optp->vmin != 1) {
|
||||||
rb_warning("min option ignored");
|
rb_warning("min option ignored");
|
||||||
}
|
}
|
||||||
if (optp->intr) {
|
if (optp->intr) {
|
||||||
w = rb_wait_for_single_fd(fptr->fd, RB_WAITFD_IN, to);
|
VALUE result = RB_NUM2INT(rb_io_wait(io, RUBY_IO_READABLE, timeout));
|
||||||
if (w < 0) rb_eof_error();
|
if (result == Qfalse) return Qnil;
|
||||||
if (!(w & RB_WAITFD_IN)) return Qnil;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rb_warning("vtime option ignored if intr flag is unset");
|
rb_warning("vtime option ignored if intr flag is unset");
|
||||||
|
@ -154,8 +154,8 @@ int rb_io_extract_encoding_option(VALUE opt, rb_encoding **enc_p, rb_encoding **
|
|||||||
void rb_io_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash, int *oflags_p, int *fmode_p, rb_io_enc_t *convconfig_p);
|
void rb_io_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash, int *oflags_p, int *fmode_p, rb_io_enc_t *convconfig_p);
|
||||||
ssize_t rb_io_bufwrite(VALUE io, const void *buf, size_t size);
|
ssize_t rb_io_bufwrite(VALUE io, const void *buf, size_t size);
|
||||||
|
|
||||||
int rb_io_wait_readable(int);
|
int rb_io_wait_readable(int fd);
|
||||||
int rb_io_wait_writable(int);
|
int rb_io_wait_writable(int fd);
|
||||||
int rb_wait_for_single_fd(int fd, int events, struct timeval *tv);
|
int rb_wait_for_single_fd(int fd, int events, struct timeval *tv);
|
||||||
|
|
||||||
VALUE rb_io_wait(VALUE io, VALUE events, VALUE timeout);
|
VALUE rb_io_wait(VALUE io, VALUE events, VALUE timeout);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user