diff options
| author | babenko <[email protected]> | 2026-07-01 10:01:53 +0300 |
|---|---|---|
| committer | babenko <[email protected]> | 2026-07-01 10:47:55 +0300 |
| commit | f26b401bceaf9d119e31b45568c41188def5176c (patch) | |
| tree | 2abf92f488b714d114cd48bdf794aad218443152 /library/cpp/yt/threading/rw_spin_lock.cpp | |
| parent | 0da783b48651ad1f2b749620d12875ab8d843615 (diff) | |
Reliable on-demand construction of TThreadLockTracker instance
commit_hash:39506fb1534ae2d5c5dfe509c9d95a7f74c2aa18
Diffstat (limited to 'library/cpp/yt/threading/rw_spin_lock.cpp')
| -rw-r--r-- | library/cpp/yt/threading/rw_spin_lock.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/library/cpp/yt/threading/rw_spin_lock.cpp b/library/cpp/yt/threading/rw_spin_lock.cpp index efc0e90167a..3150c1aa132 100644 --- a/library/cpp/yt/threading/rw_spin_lock.cpp +++ b/library/cpp/yt/threading/rw_spin_lock.cpp @@ -41,7 +41,8 @@ void TUncheckedReaderWriterSpinLock::AcquireWriterSlow() noexcept namespace { -// NB: Reading this after destruction is UB, but we can't deal with Static Initialization Order Fiasco in any other feasible way :( +// NB: Reading this after destruction is UB, but we can't deal with +// Static Initialization Order Fiasco in any other feasible way :( YT_DEFINE_THREAD_LOCAL(bool, ThreadLockTrackerDestroyed, false); class TThreadLockTracker @@ -61,13 +62,17 @@ public: ~TThreadLockTracker() { ThreadLockTrackerDestroyed() = true; - }; + } private: THashSet<TCheckedReaderWriterSpinLock*> ThreadLocksAcquired_; }; -YT_DEFINE_THREAD_LOCAL(TThreadLockTracker, ThreadLockTracker); +YT_PREVENT_TLS_CACHING static TThreadLockTracker& ThreadLockTracker() +{ + static thread_local TThreadLockTracker Instance; + return Instance; +} } // namespace |
