Define general purpose tsd_thread_event_init()

This commit is contained in:
Yinan Zhang 2019-11-01 14:11:59 -07:00
parent 97f93fa0f2
commit 43f0ce92d8
3 changed files with 31 additions and 3 deletions

View File

@ -27,6 +27,7 @@ void thread_event_trigger(tsd_t *tsd, bool delay_event);
void thread_event_rollback(tsd_t *tsd, size_t diff);
void thread_event_update(tsd_t *tsd);
void thread_event_boot();
void tsd_thread_event_init(tsd_t *tsd);
/*
* List of all events, in the following format:

View File

@ -11,6 +11,13 @@
*/
static bool thread_event_active = false;
/* TSD event init function signatures. */
#define E(event, condition) \
static void tsd_thread_##event##_event_init(tsd_t *tsd);
ITERATE_OVER_ALL_EVENTS
#undef E
/* Event handler function signatures. */
#define E(event, condition) \
static void thread_##event##_event_handler(tsd_t *tsd);
@ -18,6 +25,18 @@ static void thread_##event##_event_handler(tsd_t *tsd);
ITERATE_OVER_ALL_EVENTS
#undef E
static void
tsd_thread_tcache_gc_event_init(tsd_t *tsd) {
assert(TCACHE_GC_INCR_BYTES > 0);
thread_tcache_gc_event_update(tsd, TCACHE_GC_INCR_BYTES);
}
static void
tsd_thread_prof_sample_event_init(tsd_t *tsd) {
assert(config_prof && opt_prof);
/* Do not set sample interval until the first allocation. */
}
static void
thread_tcache_gc_event_handler(tsd_t *tsd) {
assert(TCACHE_GC_INCR_BYTES > 0);
@ -270,3 +289,13 @@ void thread_event_boot() {
ITERATE_OVER_ALL_EVENTS
#undef E
}
void tsd_thread_event_init(tsd_t *tsd) {
#define E(event, condition) \
if (condition) { \
tsd_thread_##event##_event_init(tsd); \
}
ITERATE_OVER_ALL_EVENTS
#undef E
}

View File

@ -233,9 +233,7 @@ tsd_data_init(tsd_t *tsd) {
*tsd_offset_statep_get(tsd) = config_debug ? 0 :
(uint64_t)(uintptr_t)tsd;
if (TCACHE_GC_INCR_BYTES > 0) {
thread_tcache_gc_event_update(tsd, TCACHE_GC_INCR_BYTES);
}
tsd_thread_event_init(tsd);
return tsd_tcache_enabled_data_init(tsd);
}