mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-06 07:30:28 +02:00
Remove scm_i_register_async_gc_callback
* libguile/finalizers.h: * libguile/finalizers.c (async_gc_finalizer): (scm_i_register_async_gc_callback): Remove.
This commit is contained in:
parent
75c7f79abc
commit
6ffddf5dae
2 changed files with 0 additions and 48 deletions
|
@ -389,49 +389,6 @@ scm_i_finalizer_pre_fork (void)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
async_gc_finalizer (void *ptr, void *data)
|
|
||||||
{
|
|
||||||
void **obj = ptr;
|
|
||||||
void (*callback) (void) = obj[0];
|
|
||||||
|
|
||||||
callback ();
|
|
||||||
|
|
||||||
scm_i_set_finalizer (ptr, async_gc_finalizer, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Arrange to call CALLBACK asynchronously after each GC. The callback
|
|
||||||
will be invoked from a finalizer, which may be from an async or from
|
|
||||||
another thread.
|
|
||||||
|
|
||||||
As an implementation detail, the way this works is that we allocate a
|
|
||||||
fresh object and put the callback in the object. We know that this
|
|
||||||
object should get collected the next time GC is run, so we attach a
|
|
||||||
finalizer to it to trigger the callback.
|
|
||||||
|
|
||||||
Once the callback runs, we re-attach a finalizer to that fresh object
|
|
||||||
to prepare for the next GC, and the process repeats indefinitely.
|
|
||||||
|
|
||||||
We could use the scm_after_gc_hook, but using a finalizer has the
|
|
||||||
advantage of potentially running in another thread, decreasing pause
|
|
||||||
time.
|
|
||||||
|
|
||||||
Note that libgc currently has a heuristic that adding 500 finalizable
|
|
||||||
objects will cause GC to collect rather than expand the heap,
|
|
||||||
drastically reducing performance on workloads that actually need to
|
|
||||||
expand the heap. Therefore scm_i_register_async_gc_callback is
|
|
||||||
inappropriate for using on unbounded numbers of callbacks. */
|
|
||||||
void
|
|
||||||
scm_i_register_async_gc_callback (void (*callback) (void))
|
|
||||||
{
|
|
||||||
void **obj = GC_MALLOC_ATOMIC (sizeof (void*));
|
|
||||||
|
|
||||||
obj[0] = (void*)callback;
|
|
||||||
|
|
||||||
scm_i_set_finalizer (obj, async_gc_finalizer, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
scm_set_automatic_finalization_enabled (int enabled_p)
|
scm_set_automatic_finalization_enabled (int enabled_p)
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,11 +37,6 @@ SCM_INTERNAL void scm_i_add_resuscitator (void *obj, scm_t_finalizer_proc,
|
||||||
|
|
||||||
SCM_INTERNAL void scm_i_finalizer_pre_fork (void);
|
SCM_INTERNAL void scm_i_finalizer_pre_fork (void);
|
||||||
|
|
||||||
/* CALLBACK will be called after each garbage collection. It will be
|
|
||||||
called from a finalizer, which may be from an async or from another
|
|
||||||
thread. */
|
|
||||||
SCM_INTERNAL void scm_i_register_async_gc_callback (void (*callback) (void));
|
|
||||||
|
|
||||||
/* Return true if THREAD is the finalizer thread. */
|
/* Return true if THREAD is the finalizer thread. */
|
||||||
SCM_INTERNAL int scm_i_is_finalizer_thread (struct scm_thread *thread);
|
SCM_INTERNAL int scm_i_is_finalizer_thread (struct scm_thread *thread);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue