aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/jemalloc/reg_zone.cpp
blob: 7946b87928c727e1bbf3a3e0641c9fc665c7f169 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <util/system/compiler.h>

extern "C" void je_zone_register();
 
static volatile bool initialized = false;

namespace { 
    struct TInit {
        inline TInit() { 
            if (!initialized) {
                je_zone_register();
                initialized = true;
            }
        } 
    };

    void zone_register() {
        static TInit init;
    }
} 

extern "C" {
    void je_assure_zone_register() {
        if (Y_LIKELY(initialized)) {
            return;
        }

        // Even if we have read false "initialized", real init will be syncronized once by
        // Meyers singleton in <anonymous>::register_zone(). We could do a few
        // redundant "initialized" and singleton creation checks, but no more than that.
        zone_register();
    }
}