summaryrefslogtreecommitdiff
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
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
-rw-r--r--ChangeLog10
-rw-r--r--include/ruby/intern.h2
-rw-r--r--thread.c19
3 files changed, 26 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index f4c94f4fd6..a5c63fc9bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sat Dec 15 10:22:38 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * thread.c (rb_thread_polling): revert but deprecate.
+
+ * include/ruby/intern.h (rb_thread_polling): deprecate.
+
Sat Dec 15 08:37:01 2012 Masaya Tarui <tarui@ruby-lang.org>
* test/rubygems/test_gem_ext_cmake_builder.rb(test_self_build):
@@ -31,10 +37,6 @@ Sat Dec 15 06:15:14 2012 Eric Hodel <drbrain@segment7.net>
__sync_val_compare_and_swap. Patch by KOSAKI Motohiro.
[ruby-trunk - Bug #7485]
-Sat Dec 15 04:25:11 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
-
- * include/ruby/intern.h: remove rb_thread_polling() declaration.
-
Sat Dec 15 03:42:34 2012 Naohisa Goto <ngotogenome@gmail.com>
* ext/.document: add fiddle/pointer.c, fiddle/handle.c, and
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index 1b7cabcd14..9e77533517 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -394,7 +394,7 @@ void rb_thread_wait_fd(int);
int rb_thread_fd_writable(int);
void rb_thread_fd_close(int);
int rb_thread_alone(void);
-void rb_thread_polling(void);
+DEPRECATED(void rb_thread_polling(void));
void rb_thread_sleep(int);
void rb_thread_sleep_forever(void);
VALUE rb_thread_stop(void);
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.