6#ifndef __CWIST_CORE_MEM_GC_H__
7#define __CWIST_CORE_MEM_GC_H__
11#include <ttak/compat/stdatomic.h>
12#include <ttak/mem/epoch_gc.h>
void cwist_full_gc(bool enable)
Enable or disable full-GC mode process-wide.
ttak_epoch_gc_t * cwist_gc_raw(cwist_gc_t *gc)
Obtain the raw libttak epoch GC pointer (advanced usage).
void cwist_gc_auto_rotate(cwist_gc_t *gc, bool enabled)
Toggle whether the GC context reclaims automatically.
void cwist_conn_registry_sweep_all(void)
Sweep every thread's pending-sweep list right now. This is what the process-exit (atexit) hook calls;...
bool cwist_conn_registry_untrack(void *handle)
Remove a handle from the registry before closing it yourself through the normal explicit path.
void cwist_ebr_free(void *ptr)
Defer release of a block shared across threads via epoch reclamation.
bool cwist_gc_scope_disown(void *ptr)
Remove ptr from the current thread's pending-sweep list without freeing it, because ownership is bein...
void cwist_reg_ptr(cwist_gc_t *gc, void *ptr)
Register a pointer without specifying a size (defaults to 0).
bool cwist_full_gc_enabled(void)
Check whether full-GC mode is currently enabled.
void cwist_release_guard_init(cwist_release_guard_t *guard)
Initialize a release guard to its unclaimed state.
bool cwist_conn_registry_adopt(void *handle)
Make the calling thread the owner of a tracked handle.
bool cwist_gc_auto_rotated(cwist_gc_t *gc)
Check whether the GC context is currently set to auto-rotate.
void(* cwist_conn_close_fn)(void *handle)
Full-GC's connection registry: thread/process-exit sweep for resources that aren't plain cwist_alloc(...
void cwist_gc_shutdown(cwist_gc_t *gc)
Shut down and free internal GC state.
struct cwist_gc cwist_gc_t
High-level wrapper over libttak's epoch GC.
bool cwist_release_guard_acquire(cwist_release_guard_t *guard)
Attempt to claim the guard.
void cwist_gc_rotate(cwist_gc_t *gc)
Rotate the GC epoch and reclaim retired nodes.
void cwist_gc_scope_flush(void)
Retire every block still on the current thread's pending-sweep list right now, instead of waiting for...
size_t cwist_conn_registry_pending_count(void)
Number of tracked connections the calling thread owns. Introspection/testing helper.
void cwist_gc_pipeline_tick(void)
Drive the EBR pipeline: attempt to advance the epoch and run any cwist_ebr_free() callbacks that are ...
void cwist_conn_registry_flush(void)
Close every handle the calling thread owns right now, without waiting for thread exit....
bool cwist_gc_scope_untrack(void *ptr)
Remove a block from the current thread's pending-sweep list.
bool cwist_full_gc_locked(void)
Check whether the full-GC toggle has been latched (i.e. cwist_full_gc() has been called once already ...
void cwist_reg_ptr_sized(cwist_gc_t *gc, void *ptr, size_t size)
Register a pointer and its size for better accounting.
void cwist_conn_registry_track(void *handle, cwist_conn_close_fn close_fn)
Register a connection handle for the full-GC exit sweep, owned by the calling thread (full-GC mode on...
atomic_bool cwist_release_guard_t
One-shot guard ensuring a shared teardown path runs exactly once.
void * cwist_ebr_alloc(size_t size)
Allocate a block meant to be released through cwist_ebr_free().
size_t cwist_gc_scope_pending_count(void)
Number of blocks currently on the calling thread's pending-sweep list. Introspection/testing helper.
void cwist_gc_scope_track(void *ptr)
Register a cwist_alloc() block with the current thread's pending-sweep list (full-GC mode only).
void * cwist_full_gc_guard_page(void)
Raw pointer to the full-GC toggle's guard page, or NULL if the mmap() backing it failed at process st...
High-level wrapper over libttak's epoch GC.
_Atomic bool auto_rotated
Check if GC should scan and reclaim objects.
bool initialized
Check if CWIST GC has initialized.