• Yedidya Feldblum's avatar
    Use C++ thread_local for fast-path cache in SingletonThreadLocal · d6dd4b47
    Yedidya Feldblum authored
    Summary:
    [Folly] Use C++ `thread_local` for fast-path cache in `SingletonThreadLocal`.
    
    Because modules might be `dlclose`'d, use `static thread_local` rather than `static __thread` in the slow path which integrates the dtor into both `dlclose` and thread exit.
    
    Because there might be multiple dynamically-loaded modules where the `static __thread` caches cannot be merged into a single cache, let all caches be tracked in a list. We have not found a case where this can happen while at the same time the `StaticSingletonManager` singleton does get merged, but this is at least not strictly wrong.
    
    Reviewed By: djwatson
    
    Differential Revision: D7316155
    
    fbshipit-source-id: 0bf06638853ed70464856853349445d9fa6eabc0
    d6dd4b47
SingletonThreadLocal.h 4.49 KB