guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 11/24: Remove thread held pthread_mutex field


From: Andy Wingo
Subject: [Guile-commits] 11/24: Remove thread held pthread_mutex field
Date: Sun, 6 Nov 2016 18:00:45 +0000 (UTC)

wingo pushed a commit to branch master
in repository guile.

commit a3d0a7da4d2a78a7bddbac7a93648835d8419e8f
Author: Andy Wingo <address@hidden>
Date:   Sat Nov 5 00:22:15 2016 +0100

    Remove thread held pthread_mutex field
    
    * libguile/threads.h (scm_i_thread):
    * libguile/threads.c (guilify_self_1, on_thread_exit)
      (scm_pthread_cond_wait, scm_pthread_cond_timedwait): The thread-local
      held_mutex field is no longer needed, now that we cancel threads via
      interrupts instead of pthread_cancel.
---
 libguile/threads.c |   27 ++-------------------------
 libguile/threads.h |    1 -
 2 files changed, 2 insertions(+), 26 deletions(-)

diff --git a/libguile/threads.c b/libguile/threads.c
index 76abe35..d15c4e7 100644
--- a/libguile/threads.c
+++ b/libguile/threads.c
@@ -411,7 +411,6 @@ guilify_self_1 (struct GC_stack_base *base)
   t.pthread = scm_i_pthread_self ();
   t.handle = SCM_BOOL_F;
   t.result = SCM_BOOL_F;
-  t.held_mutex = NULL;
   t.join_queue = SCM_EOL;
   t.freelists = NULL;
   t.pointerless_freelists = NULL;
@@ -568,14 +567,6 @@ on_thread_exit (void *v)
      it here.  */
   t->guile_mode = 0;
 
-  /* If this thread was cancelled while doing a cond wait, it will
-     still have a mutex locked, so we unlock it here. */
-  if (t->held_mutex)
-    {
-      scm_i_pthread_mutex_unlock (t->held_mutex);
-      t->held_mutex = NULL;
-    }
-
   /* Reinstate the current thread for purposes of scm_with_guile
      guile-mode cleanup handlers.  Only really needed in the non-TLS
      case but it doesn't hurt to be consistent.  */
@@ -1688,14 +1679,7 @@ scm_dynwind_pthread_mutex_lock (scm_i_pthread_mutex_t 
*mutex)
 int
 scm_pthread_cond_wait (scm_i_pthread_cond_t *cond, scm_i_pthread_mutex_t 
*mutex)
 {
-  int res;
-  scm_i_thread *t = SCM_I_CURRENT_THREAD;
-
-  t->held_mutex = mutex;
-  res = scm_i_pthread_cond_wait (cond, mutex);
-  t->held_mutex = NULL;
-
-  return res;
+  return scm_i_pthread_cond_wait (cond, mutex);
 }
 
 int
@@ -1703,14 +1687,7 @@ scm_pthread_cond_timedwait (scm_i_pthread_cond_t *cond,
                            scm_i_pthread_mutex_t *mutex,
                            const scm_t_timespec *wt)
 {
-  int res;
-  scm_i_thread *t = SCM_I_CURRENT_THREAD;
-
-  t->held_mutex = mutex;
-  res = scm_i_pthread_cond_timedwait (cond, mutex, wt);
-  t->held_mutex = NULL;
-
-  return res;
+  return scm_i_pthread_cond_timedwait (cond, mutex, wt);
 }
 
 #endif
diff --git a/libguile/threads.h b/libguile/threads.h
index e88a7e5..0aef61d 100644
--- a/libguile/threads.h
+++ b/libguile/threads.h
@@ -63,7 +63,6 @@ typedef struct scm_i_thread {
   SCM join_queue;
 
   scm_i_pthread_mutex_t admin_mutex;
-  scm_i_pthread_mutex_t *held_mutex;
 
   SCM result;
   int exited;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]