1 #ifndef JEMALLOC_INTERNAL_BACKGROUND_THREAD_STRUCTS_H
2 #define JEMALLOC_INTERNAL_BACKGROUND_THREAD_STRUCTS_H
4 /* This file really combines "structs" and "types", but only transitionally. */
6 #if defined(JEMALLOC_BACKGROUND_THREAD) || defined(JEMALLOC_LAZY_LOCK)
7 # define JEMALLOC_PTHREAD_CREATE_WRAPPER
10 #define BACKGROUND_THREAD_INDEFINITE_SLEEP UINT64_MAX
11 #define MAX_BACKGROUND_THREAD_LIMIT MALLOCX_ARENA_LIMIT
14 background_thread_stopped,
15 background_thread_started,
16 /* Thread waits on the global lock when paused (for arena_reset). */
17 background_thread_paused,
18 } background_thread_state_t;
20 struct background_thread_info_s {
21 #ifdef JEMALLOC_BACKGROUND_THREAD
22 /* Background thread is pthread specific. */
27 background_thread_state_t state;
28 /* When true, it means no wakeup scheduled. */
29 atomic_b_t indefinite_sleep;
30 /* Next scheduled wakeup time (absolute time in ns). */
33 * Since the last background thread run, newly added number of pages
34 * that need to be purged by the next wakeup. This is adjusted on
35 * epoch advance, and is used to determine whether we should signal the
36 * background thread to wake up earlier.
38 size_t npages_to_purge_new;
39 /* Stats: total number of runs since started. */
41 /* Stats: total sleep time since started. */
42 nstime_t tot_sleep_time;
44 typedef struct background_thread_info_s background_thread_info_t;
46 struct background_thread_stats_s {
49 nstime_t run_interval;
51 typedef struct background_thread_stats_s background_thread_stats_t;
53 #endif /* JEMALLOC_INTERNAL_BACKGROUND_THREAD_STRUCTS_H */