aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/memory/weak_ptr.h
diff options
context:
space:
mode:
authormax42 <max42@yandex-team.ru>2022-02-10 16:47:51 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:51 +0300
commit9988f7c537b40605e1a0aaae2977d5f540425b83 (patch)
treea4f3497f66e2dcd82d0f7ae7573acd1320d1bc78 /library/cpp/yt/memory/weak_ptr.h
parent0a579de32b745908473b2cea7c5cd5540bc801f0 (diff)
downloadydb-9988f7c537b40605e1a0aaae2977d5f540425b83.tar.gz
Restoring authorship annotation for <max42@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/yt/memory/weak_ptr.h')
-rw-r--r--library/cpp/yt/memory/weak_ptr.h38
1 files changed, 19 insertions, 19 deletions
diff --git a/library/cpp/yt/memory/weak_ptr.h b/library/cpp/yt/memory/weak_ptr.h
index 25a242bb8a..900f8250b8 100644
--- a/library/cpp/yt/memory/weak_ptr.h
+++ b/library/cpp/yt/memory/weak_ptr.h
@@ -246,25 +246,25 @@ TWeakPtr<T> MakeWeak(const TIntrusivePtr<T>& p)
return TWeakPtr<T>(p);
}
-//! A helper for acquiring weak pointer for pointee, resetting intrusive pointer and then
-//! returning the pointee reference count using the acquired weak pointer.
-//! This helper is designed for best effort in checking that the object is not leaked after
-//! destructing (what seems to be) the last pointer to it.
-//! NB: it is possible to rewrite this helper making it working event with intrinsic refcounted objects,
-//! but it requires much nastier integration with the intrusive pointer destruction routines.
-template <typename T>
-int ResetAndGetResidualRefCount(TIntrusivePtr<T>& pointer)
-{
- auto weakPointer = MakeWeak(pointer);
- pointer.Reset();
- if (pointer = weakPointer.Lock()) {
- // This _may_ return 0 if we are again the only holder of the pointee.
- return pointer->GetRefCount() - 1;
- } else {
- return 0;
- }
-}
-
+//! A helper for acquiring weak pointer for pointee, resetting intrusive pointer and then
+//! returning the pointee reference count using the acquired weak pointer.
+//! This helper is designed for best effort in checking that the object is not leaked after
+//! destructing (what seems to be) the last pointer to it.
+//! NB: it is possible to rewrite this helper making it working event with intrinsic refcounted objects,
+//! but it requires much nastier integration with the intrusive pointer destruction routines.
+template <typename T>
+int ResetAndGetResidualRefCount(TIntrusivePtr<T>& pointer)
+{
+ auto weakPointer = MakeWeak(pointer);
+ pointer.Reset();
+ if (pointer = weakPointer.Lock()) {
+ // This _may_ return 0 if we are again the only holder of the pointee.
+ return pointer->GetRefCount() - 1;
+ } else {
+ return 0;
+ }
+}
+
////////////////////////////////////////////////////////////////////////////////
// TODO(sandello): Kill comparsions.