diff options
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -994,6 +994,15 @@ sleep_wait_for_interrupt(rb_thread_t *th, double sleepsec,int spurious_check) sleep_timeval(th, double2timeval(sleepsec),spurious_check); } +static void +sleep_for_polling(rb_thread_t *th) +{ + struct timeval time; + time.tv_sec = 0; + time.tv_usec = 100 * 1000; /* 0.1 sec */ + sleep_timeval(th, time, 1); +} + void rb_thread_wait_for(struct timeval time) { @@ -1001,6 +1010,16 @@ rb_thread_wait_for(struct timeval time) sleep_timeval(th, time, 1); } +void +rb_thread_polling(void) +{ + if (!rb_thread_alone()) { + rb_thread_t *th = GET_THREAD(); + RUBY_VM_CHECK_INTS_BLOCKING(th); + sleep_for_polling(th); + } +} + /* * CAUTION: This function causes thread switching. * rb_thread_check_ints() check ruby's interrupts. |