summaryrefslogtreecommitdiff
path: root/libguile/goops.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2011-05-25 10:32:19 +0200
committerAndy Wingo <wingo@pobox.com>2011-05-25 10:32:19 +0200
commita099c8d971c1d5b32e00f25469b36ce45fd4d8c7 (patch)
tree350e16d9e9e01c95c366aa44ba31d03bf57ac83c /libguile/goops.c
parent9ec1573d2b9463043df79b9a2cb30acc6afaeaaa (diff)
parent7ad0737de9b7bbb5f4f938518b4905b526d13ca6 (diff)
downloadguile-a099c8d971c1d5b32e00f25469b36ce45fd4d8c7.tar.gz
Merge remote-tracking branch 'origin/stable-2.0'
Conflicts: libguile/procprop.c
Diffstat (limited to 'libguile/goops.c')
-rw-r--r--libguile/goops.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/libguile/goops.c b/libguile/goops.c
index 925f094b6..8ed37fac5 100644
--- a/libguile/goops.c
+++ b/libguile/goops.c
@@ -170,6 +170,7 @@ static SCM class_bytevector;
static SCM class_uvec;
static SCM vtable_class_map = SCM_BOOL_F;
+static scm_i_pthread_mutex_t vtable_class_map_lock = SCM_I_PTHREAD_MUTEX_INITIALIZER;
/* Port classes. Allocate 3 times the maximum number of port types so that
input ports, output ports, and in/out ports can be stored at different
@@ -197,6 +198,8 @@ scm_i_define_class_for_vtable (SCM vtable)
{
SCM class;
+ scm_i_pthread_mutex_lock (&vtable_class_map_lock);
+
if (scm_is_false (vtable_class_map))
vtable_class_map = scm_make_weak_key_hash_table (SCM_UNDEFINED);
@@ -205,6 +208,8 @@ scm_i_define_class_for_vtable (SCM vtable)
class = scm_hashq_ref (vtable_class_map, vtable, SCM_BOOL_F);
+ scm_i_pthread_mutex_unlock (&vtable_class_map_lock);
+
if (scm_is_false (class))
{
if (SCM_UNPACK (scm_class_class))
@@ -219,8 +224,12 @@ scm_i_define_class_for_vtable (SCM vtable)
else
/* `create_struct_classes' will fill this in later. */
class = SCM_BOOL_F;
-
+
+ /* Don't worry about races. This only happens when creating a
+ vtable, which happens by definition in one thread. */
+ scm_i_pthread_mutex_lock (&vtable_class_map_lock);
scm_hashq_set_x (vtable_class_map, vtable, class);
+ scm_i_pthread_mutex_unlock (&vtable_class_map_lock);
}
return class;
@@ -2671,6 +2680,7 @@ make_struct_class (void *closure SCM_UNUSED,
static void
create_struct_classes (void)
{
+ /* FIXME: take the vtable_class_map while initializing goops? */
scm_internal_hash_fold (make_struct_class, 0, SCM_BOOL_F,
vtable_class_map);
}