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

ruby-changes:8589

From: nobu <ko1@a...>
Date: Fri, 7 Nov 2008 07:12:38 +0900 (JST)
Subject: [ruby-changes:8589] Ruby:r20124 (trunk): * thread_pthread.c (thread_timer): uses pthread_cond_timedwait always

nobu	2008-11-07 07:12:20 +0900 (Fri, 07 Nov 2008)

  New Revision: 20124

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

  Log:
    * thread_pthread.c (thread_timer): uses pthread_cond_timedwait always
      instead of pthread_kill.

  Modified files:
    trunk/ChangeLog
    trunk/thread_pthread.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 20123)
+++ ChangeLog	(revision 20124)
@@ -1,3 +1,8 @@
+Fri Nov  7 07:12:06 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* thread_pthread.c (thread_timer): uses pthread_cond_timedwait always
+	  instead of pthread_kill.
+
 Fri Nov  7 04:02:22 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* thread.c (thread_timer): uses timedwait on cygwin.
Index: thread_pthread.c
===================================================================
--- thread_pthread.c	(revision 20123)
+++ thread_pthread.c	(revision 20124)
@@ -649,14 +649,6 @@
 }
 
 static pthread_t timer_thread_id;
-
-#ifdef __CYGWIN__
-#define TIMER_USE_TIMEDWAIT 1
-#endif
-#ifndef TIMER_USE_TIMEDWAIT
-#define TIMER_USE_TIMEDWAIT 0
-#endif
-#if TIMER_USE_TIMEDWAIT
 static pthread_cond_t timer_thread_cond = PTHREAD_COND_INITIALIZER;
 
 static struct timespec *
@@ -672,28 +664,15 @@
     }
     return ts;
 }
-#endif
 
 static void *
 thread_timer(void *dummy)
 {
-#if TIMER_USE_TIMEDWAIT
     struct timespec ts;
     static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
 
     pthread_mutex_lock(&lock);
 #define WAIT_FOR_10MS() (pthread_cond_timedwait(&timer_thread_cond, &lock, get_ts(&ts, PER_NANO/100)) == 0)
-#elif defined HAVE_NANOSLEEP
-    struct timespec req, rem;
-    req.tv_sec = 0;
-    req.tv_nsec = 10 * 1000 * 1000;	/* 10 ms */
-#define WAIT_FOR_10MS() (nanosleep(&req, &rem) != -1)
-#else
-    struct timeval tv;
-    tv.tv_sec = 0;
-    tv.tv_usec = 10000;     	/* 10 ms */
-#define WAIT_FOR_10MS() (select(0, NULL, NULL, NULL, &tv) != -1)
-#endif
     while (WAIT_FOR_10MS()) {
 #ifndef __CYGWIN__
 	if (signal_thread_list_anchor.next) {
@@ -709,10 +688,8 @@
 #endif
 	timer_thread_function(dummy);
     }
-#if TIMER_USE_TIMEDWAIT
     pthread_mutex_unlock(&lock);
     pthread_mutex_destroy(&lock);
-#endif
     return NULL;
 }
 
@@ -738,10 +715,6 @@
     rb_disable_interrupt(); /* only timer thread recieve signal */
 }
 
-#if TIMER_USE_TIMEDWAIT
 #define native_stop_timer_thread() pthread_cond_signal(&timer_thread_cond)
-#else
-#define native_stop_timer_thread() pthread_kill(timer_thread_id, SIGTERM)
-#endif
 
 #endif /* THREAD_SYSTEM_DEPENDENT_IMPLEMENTATION */

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

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