From de8598b63a9189af11ed65e0dd825909b0454fcd Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 15 Nov 2010 12:02:10 +0000 Subject: [PATCH] 2010-11-15 Tatsuhiro Tsujikawa Added SharedHandle::swap * src/SharedHandle.h --- ChangeLog | 5 +++++ src/SharedHandle.h | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2521ddaf..ae1d974c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-11-15 Tatsuhiro Tsujikawa + + Added SharedHandle::swap + * src/SharedHandle.h + 2010-11-14 Tatsuhiro Tsujikawa Use --max-connection-per-server option value for Metalink. diff --git a/src/SharedHandle.h b/src/SharedHandle.h index b68de026..1ec72c34 100644 --- a/src/SharedHandle.h +++ b/src/SharedHandle.h @@ -37,6 +37,7 @@ #include #include +#include // To Use std::tr1::shared_ptr uncomment following few lines and // comment out SharedHandle stuff. @@ -120,6 +121,11 @@ public: } inline size_t getRefCount() const { return refCount_->getStrongRefCount(); } + + void swap(SharedCount& r) + { + std::swap(refCount_, r.refCount_); + } }; class WeakCount { @@ -273,6 +279,12 @@ public: void reset(T* t) { *this = SharedHandle(t); } + + void swap(SharedHandle& other) + { + std::swap(obj_, other.obj_); + ucount_.swap(other.ucount_); + } }; template