summaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/threading/rw_spin_lock.cpp
diff options
context:
space:
mode:
authorYDBot <[email protected]>2026-07-02 18:29:58 +0000
committerYDBot <[email protected]>2026-07-02 18:29:58 +0000
commita52ffb856a584a5099e37b9c060da3ba4a3db5fb (patch)
tree59c7f09bdc9e52d11ce6ddf8b6fabdfe1e73a8d6 /library/cpp/yt/threading/rw_spin_lock.cpp
parent6faa15e1fbe202f0fddb7c1ffe9886dc81a0425f (diff)
parentd5cfc51dd97284c59104c50bb156d1a8d9a09dac (diff)
Merge pull request #45225 from ydb-platform/merge-rightlib-260701-1735
Diffstat (limited to 'library/cpp/yt/threading/rw_spin_lock.cpp')
-rw-r--r--library/cpp/yt/threading/rw_spin_lock.cpp11
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