1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00
guile/libguile/finalizers.h
Andy Wingo a0551390d5 consolidate scm_i_register_weak_gc_callback, update weak-set to fit
* libguile/finalizers.h:
* libguile/finalizers.c (scm_i_register_weak_gc_callback): New internal
  helper, from weak-set.c.

  Relative to the previous weak-set.c version, prefer the
  finalizer-based implementation.  Fix bug regarding confusion between
  scm_before_gc_c_hook and scm_after_gc_hook.  Fix bug regarding
  referencing weak values outside of the alloc lock.

* libguile/weak-set.c (GC_move_disappearing_link): New stub.
  GC_move_disappearing_link is only available in libgc 7.3.
  (move_weak_entry): Use the new stub instead of ifdeffery.
  (resize_set): Now that we run finalizers from a separate thread or
  async, we can keep the lock while reallocating the set vector.
  (do_vacuum_weak_set): For the same reason, always lock the set.
  Remove implementation of scm_c_register_weak_gc_callback in preference
  of the new copy in finalizers.c.
  (scm_c_make_weak_set): Use the new scm_i_register_weak_gc_callback.
2013-01-20 12:37:00 +01:00

47 lines
1.8 KiB
C
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef SCM_FINALIZERS_H
#define SCM_FINALIZERS_H
/* Copyright (C) 2012, 2013 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#include "libguile/__scm.h"
typedef void (*scm_t_finalizer_proc) (void *obj, void *data);
SCM_INTERNAL void scm_i_set_finalizer (void *obj, scm_t_finalizer_proc,
void *data);
SCM_INTERNAL void scm_i_add_finalizer (void *obj, scm_t_finalizer_proc,
void *data);
SCM_INTERNAL void scm_i_add_resuscitator (void *obj, scm_t_finalizer_proc,
void *data);
SCM_INTERNAL void scm_i_finalizer_pre_fork (void);
/* CALLBACK will be called on OBJ after each garbage collection, as long
as OBJ is accessible. It will be called from a finalizer, which may
be from an async or from another thread. */
SCM_INTERNAL void scm_i_register_weak_gc_callback (SCM obj, void (*callback) (SCM));
SCM_INTERNAL void scm_init_finalizers (void);
SCM_INTERNAL void scm_init_finalizer_thread (void);
#endif /* SCM_FINALIZERS_H */