1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-09 13:30:26 +02:00

Add try-push, swap-value API to ephemerons

The former allows for knowing whether a push succeeded or not, which is
useful for concurrent hash tables.  The latter makes ephemerons mutable,
if the embedder wants to use them that way.
This commit is contained in:
Andy Wingo 2025-05-09 09:56:17 +02:00
parent c86408a33c
commit a5c69fb920
7 changed files with 74 additions and 8 deletions

View file

@ -1007,6 +1007,14 @@ gc_ephemeron_init(struct gc_mutator *mut, struct gc_ephemeron *ephemeron,
// key or the value.
}
struct gc_ref
gc_ephemeron_swap_value(struct gc_mutator *mut, struct gc_ephemeron *e,
struct gc_ref ref) {
gc_write_barrier(mut, gc_ref_from_heap_object(e), gc_ephemeron_size(),
gc_ephemeron_value_edge(e), ref);
return gc_ephemeron_swap_value_internal(e, ref);
}
struct gc_pending_ephemerons *
gc_heap_pending_ephemerons(struct gc_heap *heap) {
return heap->pending_ephemerons;