[thread_event] Remove macros from thread_event and replace with dynamic event objects

This commit is contained in:
Slobodan Predolac
2025-03-14 06:34:05 -07:00
committed by Guangli Dai
parent 1972241cd2
commit e6864c6075
17 changed files with 455 additions and 318 deletions

View File

@@ -511,7 +511,7 @@ tcache_try_gc_bin(tsd_t *tsd, tcache_slow_t *tcache_slow, tcache_t *tcache,
}
static void
tcache_event(tsd_t *tsd) {
tcache_gc_event(tsd_t *tsd) {
tcache_t *tcache = tcache_get(tsd);
if (tcache == NULL) {
return;
@@ -581,18 +581,6 @@ tcache_event(tsd_t *tsd) {
tcache_slow->next_gc_bin_large = szind_large;
}
void
tcache_gc_event_handler(tsd_t *tsd, uint64_t elapsed) {
assert(elapsed == TE_INVALID_ELAPSED);
tcache_event(tsd);
}
void
tcache_gc_dalloc_event_handler(tsd_t *tsd, uint64_t elapsed) {
assert(elapsed == TE_INVALID_ELAPSED);
tcache_event(tsd);
}
void *
tcache_alloc_small_hard(tsdn_t *tsdn, arena_t *arena,
tcache_t *tcache, cache_bin_t *cache_bin, szind_t binind,
@@ -1912,3 +1900,16 @@ tcache_postfork_child(tsdn_t *tsdn) {
void tcache_assert_initialized(tcache_t *tcache) {
assert(!cache_bin_still_zero_initialized(&tcache->bins[0]));
}
static bool
tcache_gc_enabled(void) {
return (opt_tcache_gc_incr_bytes > 0);
}
/* Handles alloc and dalloc the same way */
te_base_cb_t tcache_gc_te_handler = {
.enabled = &tcache_gc_enabled,
.new_event_wait = &tcache_gc_new_event_wait,
.postponed_event_wait = &tcache_gc_postponed_event_wait,
.event_handler = &tcache_gc_event,
};