aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/ytalloc/impl
diff options
context:
space:
mode:
authorhor911 <hor911@ydb.tech>2022-07-16 18:10:10 +0300
committerhor911 <hor911@ydb.tech>2022-07-16 18:10:10 +0300
commit7537371746d95bc04135888d09ac2068233932ea (patch)
tree39204ff36893a0289cd4a100f12840f1647d4ecf /library/cpp/ytalloc/impl
parent1fa71dfe5f97c247426cdba8779a5850b62b69dd (diff)
downloadydb-7537371746d95bc04135888d09ac2068233932ea.tar.gz
Consistent logging
Diffstat (limited to 'library/cpp/ytalloc/impl')
-rw-r--r--library/cpp/ytalloc/impl/core-inl.h46
1 files changed, 12 insertions, 34 deletions
diff --git a/library/cpp/ytalloc/impl/core-inl.h b/library/cpp/ytalloc/impl/core-inl.h
index c66e8478b5c..e8e5d254422 100644
--- a/library/cpp/ytalloc/impl/core-inl.h
+++ b/library/cpp/ytalloc/impl/core-inl.h
@@ -7,6 +7,7 @@
#include <library/cpp/yt/containers/intrusive_linked_list.h>
+#include <library/cpp/yt/threading/at_fork.h>
#include <library/cpp/yt/threading/fork_aware_spin_lock.h>
#include <util/system/tls.h>
@@ -1847,11 +1848,10 @@ public:
{
pthread_key_create(&ThreadDtorKey_, DestroyThread);
- NThreading::TForkAwareSpinLock::AtFork(
- this,
+ NThreading::RegisterAtForkHandlers(
nullptr,
nullptr,
- &AfterFork);
+ [=] { AfterFork(); });
}
// Returns TThreadState for the current thread; the caller guarantees that this
@@ -2022,8 +2022,7 @@ private:
void DestroyThreadState(TThreadState* state);
- static void AfterFork(void* cookie);
- void DoAfterFork();
+ void AfterFork();
private:
// TThreadState instance for the current thread.
@@ -4208,11 +4207,10 @@ public:
TBackgroundThreadBase()
: State_(new TState())
{
- NThreading::TForkAwareSpinLock::AtFork(
- static_cast<T*>(this),
- &BeforeFork,
- &AfterForkParent,
- &AfterForkChild);
+ NThreading::RegisterAtForkHandlers(
+ [=] { BeforeFork(); },
+ [=] { AfterForkParent(); },
+ [=] { AfterForkChild(); });
}
virtual ~TBackgroundThreadBase()
@@ -4240,12 +4238,7 @@ private:
TState* State_;
private:
- static void BeforeFork(void* cookie)
- {
- static_cast<T*>(cookie)->DoBeforeFork();
- }
-
- void DoBeforeFork()
+ void BeforeFork()
{
bool stopped = Stop();
if (State_->ForkDepth++ == 0) {
@@ -4253,12 +4246,7 @@ private:
}
}
- static void AfterForkParent(void* cookie)
- {
- static_cast<T*>(cookie)->DoAfterForkParent();
- }
-
- void DoAfterForkParent()
+ void AfterForkParent()
{
if (--State_->ForkDepth == 0) {
if (State_->RestartAfterFork) {
@@ -4267,12 +4255,7 @@ private:
}
}
- static void AfterForkChild(void* cookie)
- {
- static_cast<T*>(cookie)->DoAfterForkChild();
- }
-
- void DoAfterForkChild()
+ void AfterForkChild()
{
bool restart = State_->RestartAfterFork;
State_ = new TState();
@@ -4531,12 +4514,7 @@ void TThreadManager::DestroyThreadState(TThreadState* state)
ThreadStatePool_.Free(state);
}
-void TThreadManager::AfterFork(void* cookie)
-{
- static_cast<TThreadManager*>(cookie)->DoAfterFork();
-}
-
-void TThreadManager::DoAfterFork()
+void TThreadManager::AfterFork()
{
auto guard = GuardWithTiming(ThreadRegistryLock_);
ThreadRegistry_.Clear();