diff options
author | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-02-21 13:09:08 +0300 |
---|---|---|
committer | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-02-21 13:09:08 +0300 |
commit | b99d6e954b74694820a0964402003eb9f14da4de (patch) | |
tree | 8814902312bae587822187234b721ef2d9675cf9 /library/cpp | |
parent | 96a6a371c53651ccfd7dfdc87fe354cf23de9b5c (diff) | |
download | ydb-b99d6e954b74694820a0964402003eb9f14da4de.tar.gz |
intermediate changes
ref:ff022ac951849edb1ef2cc274bf6c1c6863144a1
Diffstat (limited to 'library/cpp')
-rw-r--r-- | library/cpp/yt/memory/leaky_ref_counted_singleton-inl.h | 8 | ||||
-rw-r--r-- | library/cpp/yt/memory/leaky_ref_counted_singleton.h | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/library/cpp/yt/memory/leaky_ref_counted_singleton-inl.h b/library/cpp/yt/memory/leaky_ref_counted_singleton-inl.h index a68ec5ed6ae..7d50dcc2efd 100644 --- a/library/cpp/yt/memory/leaky_ref_counted_singleton-inl.h +++ b/library/cpp/yt/memory/leaky_ref_counted_singleton-inl.h @@ -16,8 +16,8 @@ namespace NYT { //////////////////////////////////////////////////////////////////////////////// -template <class T> -TIntrusivePtr<T> LeakyRefCountedSingleton() +template <class T, class... TArgs> +TIntrusivePtr<T> LeakyRefCountedSingleton(TArgs&&... args) { static std::atomic<T*> Ptr; auto* ptr = Ptr.load(std::memory_order_acquire); @@ -26,8 +26,8 @@ TIntrusivePtr<T> LeakyRefCountedSingleton() } static std::once_flag Initialized; - std::call_once(Initialized, [] { - auto ptr = New<T>(); + std::call_once(Initialized, [&] { + auto ptr = New<T>(std::forward<TArgs>(args)...); Ref(ptr.Get()); Ptr.store(ptr.Get()); #if defined(_asan_enabled_) diff --git a/library/cpp/yt/memory/leaky_ref_counted_singleton.h b/library/cpp/yt/memory/leaky_ref_counted_singleton.h index 1d5761bd9de..4ad5b5f0528 100644 --- a/library/cpp/yt/memory/leaky_ref_counted_singleton.h +++ b/library/cpp/yt/memory/leaky_ref_counted_singleton.h @@ -6,8 +6,8 @@ namespace NYT { //////////////////////////////////////////////////////////////////////////////// -template <class T> -TIntrusivePtr<T> LeakyRefCountedSingleton(); +template <class T, class... TArgs> +TIntrusivePtr<T> LeakyRefCountedSingleton(TArgs&&... args); //////////////////////////////////////////////////////////////////////////////// |