guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] 10/17: Mutex instead of critical section in GOOPS


From: Andy Wingo
Subject: [Guile-commits] 10/17: Mutex instead of critical section in GOOPS
Date: Tue, 1 Nov 2016 22:50:44 +0000 (UTC)

wingo pushed a commit to branch master
in repository guile.

commit e7e7a719bace8b71b351b9305940a7b4a724cc81
Author: Andy Wingo <address@hidden>
Date:   Tue Nov 1 22:52:12 2016 +0100

    Mutex instead of critical section in GOOPS
    
    * libguile/goops.c (scm_sys_modify_instance)
      (scm_sys_modify_class): Use a mutex instead of a critical section.
---
 libguile/goops.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libguile/goops.c b/libguile/goops.c
index 4e28d06..8ed0f60 100644
--- a/libguile/goops.c
+++ b/libguile/goops.c
@@ -475,6 +475,8 @@ SCM_DEFINE (scm_sys_clear_fields_x, "%clear-fields!", 2, 0, 
0,
 
 
 
+static scm_i_pthread_mutex_t goops_lock = SCM_I_PTHREAD_MUTEX_INITIALIZER;
+
 SCM_DEFINE (scm_sys_modify_instance, "%modify-instance", 2, 0, 0,
            (SCM old, SCM new),
            "Used by change-class to modify objects in place.")
@@ -487,7 +489,7 @@ SCM_DEFINE (scm_sys_modify_instance, "%modify-instance", 2, 
0, 0,
    * scratch the old value with new to be correct with GC.
    * See "Class redefinition protocol above".
    */
-  SCM_CRITICAL_SECTION_START;
+  scm_i_pthread_mutex_lock (&goops_lock);
   {
     scm_t_bits word0, word1;
     word0 = SCM_CELL_WORD_0 (old);
@@ -497,7 +499,7 @@ SCM_DEFINE (scm_sys_modify_instance, "%modify-instance", 2, 
0, 0,
     SCM_SET_CELL_WORD_0 (new, word0);
     SCM_SET_CELL_WORD_1 (new, word1);
   }
-  SCM_CRITICAL_SECTION_END;
+  scm_i_pthread_mutex_unlock (&goops_lock);
   return SCM_UNSPECIFIED;
 }
 #undef FUNC_NAME
@@ -510,7 +512,7 @@ SCM_DEFINE (scm_sys_modify_class, "%modify-class", 2, 0, 0,
   SCM_VALIDATE_CLASS (1, old);
   SCM_VALIDATE_CLASS (2, new);
 
-  SCM_CRITICAL_SECTION_START;
+  scm_i_pthread_mutex_lock (&goops_lock);
   {
     scm_t_bits word0, word1;
     word0 = SCM_CELL_WORD_0 (old);
@@ -522,7 +524,7 @@ SCM_DEFINE (scm_sys_modify_class, "%modify-class", 2, 0, 0,
     SCM_SET_CELL_WORD_1 (new, word1);
     SCM_STRUCT_DATA (new)[scm_vtable_index_self] = SCM_UNPACK (new);
   }
-  SCM_CRITICAL_SECTION_END;
+  scm_i_pthread_mutex_unlock (&goops_lock);
   return SCM_UNSPECIFIED;
 }
 #undef FUNC_NAME



reply via email to

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