summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-15 01:22:44 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-15 01:22:44 +0000
commitce6a2c7fac7123e76f457dfca77964b38875ff46 (patch)
treea5f874cceaa74df420ec66ed6e736338c1ff3da5 /thread.c
parentcb6917d9138d33d1206d9f47d419aa24e212e24e (diff)
thread.c: revert r38382 but deprecate rb_thread_polling()
* thread.c (rb_thread_polling): revert but deprecate. * include/ruby/intern.h (rb_thread_polling): deprecate. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/thread.c b/thread.c
index 56eddca895..4ea4c58f5d 100644
--- a/thread.c
+++ b/thread.c
@@ -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.