Update copyright.
[bpt/guile.git] / libguile / coop.c
index a6ef33e..ca057b4 100644 (file)
@@ -40,7 +40,7 @@
  * If you do not wish that, delete this exception notice.  */
 \f
 
-/* $Id: coop.c,v 1.27 2001-03-10 03:09:07 mdj Exp $ */
+/* $Id: coop.c,v 1.29 2001-11-04 15:52:29 ela Exp $ */
 
 /* Cooperative thread library, based on QuickThreads */
 
@@ -171,6 +171,7 @@ static pthread_cond_t coop_cond_quit;
 static pthread_cond_t coop_cond_create;
 static pthread_mutex_t coop_mutex_create;
 static pthread_t coop_mother;
+static int mother_awake_p = 0;
 static coop_t *coop_child;
 #endif
 
@@ -421,7 +422,13 @@ coop_condition_variable_timed_wait_mutex (coop_c *c,
                                          const struct timespec *abstime)
 {
   coop_t *old, *t;
+#ifdef ETIMEDOUT
   int res = ETIMEDOUT;
+#elif defined (WSAETIMEDOUT)
+  int res = WSAETIMEDOUT;
+#else
+  int res = 0;
+#endif
 
   /* coop_mutex_unlock (m); */
   t = coop_qget (&(m->waiting));
@@ -584,6 +591,7 @@ mother (void *dummy)
                      NULL,
                      dummy_start,
                      coop_child);
+      mother_awake_p = 0;
       do
        res = pthread_cond_wait (&coop_cond_create, &coop_mutex_create);
       while (res == EINTR);
@@ -618,6 +626,7 @@ coop_create (coop_userf_t *f, void *pu)
       t->n_keys = 0;
 #ifdef GUILE_PTHREAD_COMPAT
       coop_child = t;
+      mother_awake_p = 1;
       if (coop_quitting_p < 0)
        {
          coop_quitting_p = 0;
@@ -635,7 +644,7 @@ coop_create (coop_userf_t *f, void *pu)
        * condition variable because they are not safe against
        * pre-emptive switching.
        */
-      while (coop_child)
+      while (coop_child || mother_awake_p)
        usleep (0);
 #else
       t->sto = malloc (COOP_STKSIZE);
@@ -839,7 +848,6 @@ scm_thread_usleep (unsigned long usec)
 {
   /* We're so cheap.  */
   scm_thread_sleep (usec / 1000000);
-  struct timeval timeout;
   return 0;  /* Maybe we should calculate actual time slept,
                but this is faster... :) */
 }