diff options
author | Andy Wingo <wingo@pobox.com> | 2025-04-11 14:10:41 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2025-04-11 14:10:41 +0200 |
commit | db181e67ff482ab08cbdb0c1a88997b3a886f900 (patch) | |
tree | 6d16fbca515ae3cf506a9d16dbc89c472446e5d9 /libguile/whippet/api/gc-ephemeron.h | |
parent | af96820e072d18c49ac03e80c6f3466d568dc77d (diff) | |
parent | f909438596f63ecd44c5b9a28385260714857361 (diff) | |
download | guile-db181e67ff482ab08cbdb0c1a88997b3a886f900.tar.gz |
Merged Whippet into libguile/whippet
Diffstat (limited to 'libguile/whippet/api/gc-ephemeron.h')
-rw-r--r-- | libguile/whippet/api/gc-ephemeron.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/libguile/whippet/api/gc-ephemeron.h b/libguile/whippet/api/gc-ephemeron.h new file mode 100644 index 000000000..1d9e59b55 --- /dev/null +++ b/libguile/whippet/api/gc-ephemeron.h @@ -0,0 +1,42 @@ +#ifndef GC_EPHEMERON_H_ +#define GC_EPHEMERON_H_ + +#include "gc-edge.h" +#include "gc-ref.h" +#include "gc-visibility.h" + +// Ephemerons establish an association between a "key" object and a +// "value" object. If the ephemeron and the key are live, then the +// value is live, and can be retrieved from the ephemeron. Ephemerons +// can be chained together, which allows them to function as links in a +// buckets-and-chains hash table. +// +// This file defines the user-facing API for ephemerons. + +struct gc_heap; +struct gc_mutator; +struct gc_ephemeron; + +GC_API_ size_t gc_ephemeron_size(void); +GC_API_ struct gc_ephemeron* gc_allocate_ephemeron(struct gc_mutator *mut); +GC_API_ void gc_ephemeron_init(struct gc_mutator *mut, + struct gc_ephemeron *ephemeron, + struct gc_ref key, struct gc_ref value); + +GC_API_ struct gc_ref gc_ephemeron_key(struct gc_ephemeron *ephemeron); +GC_API_ struct gc_ref gc_ephemeron_value(struct gc_ephemeron *ephemeron); + +GC_API_ struct gc_ephemeron* gc_ephemeron_chain_head(struct gc_ephemeron **loc); +GC_API_ void gc_ephemeron_chain_push(struct gc_ephemeron **loc, + struct gc_ephemeron *ephemeron); +GC_API_ struct gc_ephemeron* gc_ephemeron_chain_next(struct gc_ephemeron *ephemeron); +GC_API_ void gc_ephemeron_mark_dead(struct gc_ephemeron *ephemeron); + +GC_API_ void gc_trace_ephemeron(struct gc_ephemeron *ephemeron, + void (*visit)(struct gc_edge edge, + struct gc_heap *heap, + void *visit_data), + struct gc_heap *heap, + void *trace_data); + +#endif // GC_EPHEMERON_H_ |