[前][次][番号順一覧][スレッド一覧]

ruby-changes:20254

From: kosaki <ko1@a...>
Date: Thu, 30 Jun 2011 02:36:09 +0900 (JST)
Subject: [ruby-changes:20254] kosaki:r32302 (trunk): * thread.c (rb_thread_schedule_rec): move interrupt_flag check to

kosaki	2011-06-30 02:36:00 +0900 (Thu, 30 Jun 2011)

  New Revision: 32302

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32302

  Log:
    * thread.c (rb_thread_schedule_rec): move interrupt_flag check to
      rb_thread_schedule().
      And also rename to rb_thead_schedule_limits() and remove
      sched_depth argument. It's no longer called recursive.
    * thread.c (rb_thread_schedule): add to check interrupt_flag as
      above explained.
    
    * thread.c (rb_threadptr_execute_interrupts_rec): rename to
      rb_threadptr_execute_interrupts_common() and remove sched_depth
      argument. It's no longer called recursive.
    
    * thread.c (rb_thread_sleep): adapt the renaming.
    * thread.c (rb_threadptr_execute_interrupts): ditto.
    * thread.c (rb_thread_execute_interrupts): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/thread.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 32301)
+++ ChangeLog	(revision 32302)
@@ -1,3 +1,20 @@
+Thu Jun 30 02:28:11 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* thread.c (rb_thread_schedule_rec): move interrupt_flag check to
+	  rb_thread_schedule().
+	  And also rename to rb_thead_schedule_limits() and remove
+	  sched_depth argument. It's no longer called recursive.
+	* thread.c (rb_thread_schedule): add to check interrupt_flag as
+	  above explained.
+
+	* thread.c (rb_threadptr_execute_interrupts_rec): rename to
+	  rb_threadptr_execute_interrupts_common() and remove sched_depth
+	  argument. It's no longer called recursive.
+
+	* thread.c (rb_thread_sleep): adapt the renaming.
+	* thread.c (rb_threadptr_execute_interrupts): ditto.
+	* thread.c (rb_thread_execute_interrupts): ditto.
+
 Thu Jun 30 01:31:33 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* thread.c (thread_s_pass): change RDoc description and remove
Index: thread.c
===================================================================
--- thread.c	(revision 32301)
+++ thread.c	(revision 32302)
@@ -999,10 +999,10 @@
     rb_thread_wait_for(rb_time_timeval(INT2FIX(sec)));
 }
 
-static void rb_threadptr_execute_interrupts_rec(rb_thread_t *, int);
+static void rb_threadptr_execute_interrupts_common(rb_thread_t *);
 
 static void
-rb_thread_schedule_rec(int sched_depth, unsigned long limits_us)
+rb_thread_schedule_limits(unsigned long limits_us)
 {
     thread_debug("rb_thread_schedule\n");
     if (!rb_thread_alone()) {
@@ -1017,17 +1017,17 @@
 
 	rb_thread_set_current(th);
 	thread_debug("rb_thread_schedule/switch done\n");
-
-        if (UNLIKELY(!sched_depth && GET_THREAD()->interrupt_flag)) {
-            rb_threadptr_execute_interrupts_rec(GET_THREAD(), sched_depth+1);
-        }
     }
 }
 
 void
 rb_thread_schedule(void)
 {
-    rb_thread_schedule_rec(0, 0);
+    rb_thread_schedule_limits(0);
+
+    if (UNLIKELY(GET_THREAD()->interrupt_flag)) {
+	rb_threadptr_execute_interrupts_common(GET_THREAD());
+    }
 }
 
 /* blocking region */
@@ -1261,7 +1261,7 @@
  */
 
 static void
-rb_threadptr_execute_interrupts_rec(rb_thread_t *th, int sched_depth)
+rb_threadptr_execute_interrupts_common(rb_thread_t *th)
 {
     rb_atomic_t interrupt;
 
@@ -1305,7 +1305,7 @@
 	    rb_gc_finalize_deferred();
 	}
 
-	if (!sched_depth && timer_interrupt) {
+	if (timer_interrupt) {
 	    unsigned long limits_us = 250 * 1000;
 
 	    if (th->priority > 0)
@@ -1316,10 +1316,9 @@
 	    if (status == THREAD_RUNNABLE)
 		th->running_time_us += TIME_QUANTUM_USEC;
 
-	    sched_depth++;
 	    EXEC_EVENT_HOOK(th, RUBY_EVENT_SWITCH, th->cfp->self, 0, 0);
 
-	    rb_thread_schedule_rec(sched_depth+1, limits_us);
+	    rb_thread_schedule_limits(limits_us);
 	}
     }
 }
@@ -1327,7 +1326,7 @@
 void
 rb_threadptr_execute_interrupts(rb_thread_t *th)
 {
-    rb_threadptr_execute_interrupts_rec(th, 0);
+    rb_threadptr_execute_interrupts_common(th);
 }
 
 void
@@ -1335,7 +1334,7 @@
 {
     rb_thread_t *th;
     GetThreadPtr(thval, th);
-    rb_threadptr_execute_interrupts_rec(th, 0);
+    rb_threadptr_execute_interrupts_common(th);
 }
 
 void

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]