• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //! Test background threads run-time default settings.
2 
3 use tikv_jemallocator::Jemalloc;
4 
5 #[global_allocator]
6 static A: Jemalloc = Jemalloc;
7 
8 // Returns true if background threads are enabled.
background_threads() -> bool9 fn background_threads() -> bool {
10     tikv_jemalloc_ctl::opt::background_thread::read().unwrap()
11 }
12 
13 #[test]
background_threads_runtime_defaults()14 fn background_threads_runtime_defaults() {
15     if !cfg!(feature = "background_threads_runtime_support") {
16         // If the crate was compiled without background thread support,
17         // then background threads are always disabled at run-time by default:
18         assert!(!background_threads());
19         return;
20     }
21 
22     assert_eq!(background_threads(), cfg!(feature = "background_threads"));
23 }
24