diff --git a/libguile/weak-set.c b/libguile/weak-set.c index 93c429346..1a5bc1577 100644 --- a/libguile/weak-set.c +++ b/libguile/weak-set.c @@ -1,4 +1,4 @@ -/* Copyright 2011-2013,2018 +/* Copyright 2011-2013,2018,2025 Free Software Foundation, Inc. This file is part of Guile. @@ -689,32 +689,6 @@ scm_i_weak_set_print (SCM exp, SCM port, scm_print_state *pstate) scm_puts (">", port); } -static void -do_vacuum_weak_set (SCM set) -{ - scm_t_weak_set *s; - - s = SCM_WEAK_SET (set); - - /* We should always be able to grab this lock, because we are run from - a finalizer, which runs in another thread (or an async, which is - mostly equivalent). */ - scm_i_pthread_mutex_lock (&s->lock); - vacuum_weak_set (s); - scm_i_pthread_mutex_unlock (&s->lock); -} - -static scm_i_pthread_mutex_t all_weak_sets_lock = SCM_I_PTHREAD_MUTEX_INITIALIZER; -static SCM all_weak_sets = SCM_EOL; - -static void -vacuum_all_weak_sets (void) -{ - scm_i_pthread_mutex_lock (&all_weak_sets_lock); - scm_i_visit_weak_list (&all_weak_sets, do_vacuum_weak_set); - scm_i_pthread_mutex_unlock (&all_weak_sets_lock); -} - SCM scm_c_make_weak_set (unsigned long k) { @@ -722,10 +696,6 @@ scm_c_make_weak_set (unsigned long k) ret = make_weak_set (k); - scm_i_pthread_mutex_lock (&all_weak_sets_lock); - all_weak_sets = scm_i_weak_cons (ret, all_weak_sets); - scm_i_pthread_mutex_unlock (&all_weak_sets_lock); - return ret; } @@ -902,6 +872,4 @@ void scm_init_weak_set () { #include "weak-set.x" - - scm_i_register_async_gc_callback (vacuum_all_weak_sets); } diff --git a/libguile/weak-table.c b/libguile/weak-table.c index 1e4d8d302..571511256 100644 --- a/libguile/weak-table.c +++ b/libguile/weak-table.c @@ -1,4 +1,4 @@ -/* Copyright 2011-2014,2017-2018 +/* Copyright 2011-2014,2017-2018,2025 Free Software Foundation, Inc. This file is part of Guile. @@ -458,43 +458,6 @@ scm_i_weak_table_print (SCM exp, SCM port, scm_print_state *pstate) scm_puts (">", port); } -static void -do_vacuum_weak_table (SCM table) -{ - scm_t_weak_table *t; - - t = SCM_WEAK_TABLE (table); - - /* Unlike weak sets, the weak table interface allows custom predicates - to call out to arbitrary Scheme. There are two ways that this code - can be re-entrant, then: calling weak hash procedures while in a - custom predicate, or via finalizers run explicitly by (gc) or in an - async (for non-threaded Guile). We add a restriction that - prohibits the first case, by convention. But since we can't - prohibit the second case, here we trylock instead of lock. In any - case, if the mutex is held by another thread, then the table is in - active use, so the next user of the table will handle the vacuum - for us. */ - if (scm_i_pthread_mutex_trylock (&t->lock) == 0) - { - vacuum_weak_table (t); - scm_i_pthread_mutex_unlock (&t->lock); - } - - return; -} - -static scm_i_pthread_mutex_t all_weak_tables_lock = SCM_I_PTHREAD_MUTEX_INITIALIZER; -static SCM all_weak_tables = SCM_EOL; - -static void -vacuum_all_weak_tables (void) -{ - scm_i_pthread_mutex_lock (&all_weak_tables_lock); - scm_i_visit_weak_list (&all_weak_tables, do_vacuum_weak_table); - scm_i_pthread_mutex_unlock (&all_weak_tables_lock); -} - SCM scm_c_make_weak_table (unsigned long k, scm_t_weak_table_kind kind) { @@ -502,10 +465,6 @@ scm_c_make_weak_table (unsigned long k, scm_t_weak_table_kind kind) ret = make_weak_table (k, kind); - scm_i_pthread_mutex_lock (&all_weak_tables_lock); - all_weak_tables = scm_i_weak_cons (ret, all_weak_tables); - scm_i_pthread_mutex_unlock (&all_weak_tables_lock); - return ret; } @@ -840,6 +799,4 @@ void scm_init_weak_table () { #include "weak-table.x" - - scm_i_register_async_gc_callback (vacuum_all_weak_tables); }