MCPcopy Create free account
hub / github.com/catboost/catboost / ResetAndGetResidualRefCount

Method ResetAndGetResidualRefCount

library/cpp/yt/memory/weak_ptr.h:269–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

267//! but it requires much nastier integration with the intrusive pointer destruction routines.
268template <typename T>
269int ResetAndGetResidualRefCount(TIntrusivePtr<T>& pointer)
270{
271 auto weakPointer = MakeWeak(pointer);
272 pointer.Reset();
273 pointer = weakPointer.Lock();
274 if (pointer) {
275 // This _may_ return 0 if we are again the only holder of the pointee.
276 return pointer->GetRefCount() - 1;
277 } else {
278 return 0;
279 }
280}
281
282////////////////////////////////////////////////////////////////////////////////
283

Callers

nothing calls this directly

Calls 3

GetRefCountMethod · 0.80
ResetMethod · 0.45
LockMethod · 0.45

Tested by

no test coverage detected