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

ruby-changes:6468

From: nobu <ko1@a...>
Date: Thu, 10 Jul 2008 12:10:35 +0900 (JST)
Subject: [ruby-changes:6468] Ruby:r17984 (trunk): * thread.c (rb_thread_wait_for): wait until timed out only when

nobu	2008-07-10 12:09:23 +0900 (Thu, 10 Jul 2008)

  New Revision: 17984

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

  Log:
    * thread.c (rb_thread_wait_for): wait until timed out only when
      sleeping with timeout.

  Modified files:
    trunk/ChangeLog
    trunk/thread.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 17983)
+++ ChangeLog	(revision 17984)
@@ -1,3 +1,8 @@
+Thu Jul 10 12:09:21 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* thread.c (rb_thread_wait_for): wait until timed out only when
+	  sleeping with timeout.
+
 Wed Jul  9 22:41:16 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* thread.c (sleep_timeval): wait until timed out.  [ruby-core:17270]
Index: thread.c
===================================================================
--- thread.c	(revision 17983)
+++ thread.c	(revision 17984)
@@ -736,29 +736,7 @@
 static void
 sleep_timeval(rb_thread_t *th, struct timeval tv)
 {
-    struct timeval to, tvn;
-
-    getclockofday(&to);
-    to.tv_sec += tv.tv_sec;
-    if ((to.tv_usec += tv.tv_usec) >= 1000000) {
-	to.tv_sec++;
-	to.tv_usec -= 1000000;
-    }
-
-    for (;;) {
-	native_sleep(th, &tv, 0);
-	getclockofday(&tvn);
-	if (to.tv_sec < tvn.tv_sec) break;
-	if (to.tv_sec == tvn.tv_sec && to.tv_usec <= tvn.tv_usec) break;
-	thread_debug("sleep_timeval: %ld.%.6ld > %ld.%.6ld\n",
-		     (long)to.tv_sec, to.tv_usec,
-		     (long)tvn.tv_sec, tvn.tv_usec);
-	tv.tv_sec = to.tv_sec - tvn.tv_sec;
-	if ((tv.tv_usec = to.tv_usec - tvn.tv_usec) < 0) {
-	    --tv.tv_sec;
-	    tv.tv_usec += 1000000;
-	}
-    }
+    native_sleep(th, &tv, 0);
 }
 
 void
@@ -811,7 +789,29 @@
 rb_thread_wait_for(struct timeval time)
 {
     rb_thread_t *th = GET_THREAD();
-    sleep_timeval(th, time);
+    struct timeval to, tvn;
+
+    getclockofday(&to);
+    to.tv_sec += tv.tv_sec;
+    if ((to.tv_usec += tv.tv_usec) >= 1000000) {
+	to.tv_sec++;
+	to.tv_usec -= 1000000;
+    }
+
+    for (;;) {
+	sleep_timeval(th, time);
+	getclockofday(&tvn);
+	if (to.tv_sec < tvn.tv_sec) break;
+	if (to.tv_sec == tvn.tv_sec && to.tv_usec <= tvn.tv_usec) break;
+	thread_debug("sleep_timeval: %ld.%.6ld > %ld.%.6ld\n",
+		     (long)to.tv_sec, to.tv_usec,
+		     (long)tvn.tv_sec, tvn.tv_usec);
+	tv.tv_sec = to.tv_sec - tvn.tv_sec;
+	if ((tv.tv_usec = to.tv_usec - tvn.tv_usec) < 0) {
+	    --tv.tv_sec;
+	    tv.tv_usec += 1000000;
+	}
+    }
 }
 
 void

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

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