You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2016/05/07 16:07:40 UTC

[trafficserver] 01/02: Remove unused NonAtomicPtr.

This is an automated email from the ASF dual-hosted git repository.

jpeach pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

commit 72abdb9a1d77cabae63a6105267da655af5d1367
Author: James Peach <jp...@apache.org>
AuthorDate: Wed May 4 21:24:13 2016 -0700

    Remove unused NonAtomicPtr.
---
 lib/ts/Ptr.h | 197 +----------------------------------------------------------
 1 file changed, 3 insertions(+), 194 deletions(-)

diff --git a/lib/ts/Ptr.h b/lib/ts/Ptr.h
index c43330a..a8d130a 100644
--- a/lib/ts/Ptr.h
+++ b/lib/ts/Ptr.h
@@ -21,202 +21,11 @@
   limitations under the License.
  */
 
-/*************************** -*- Mod: C++ -*- ******************************
-
-   Atmic and non-atomic smart pointers.
-
-   Note: it would have been nice to have one 'Ptr' class, but the
-   templating system on some compilers is so broken that it cannot
-   correctly compile Ptr without downcasting the m_ptr object to
-   a RefCountObj.
-
-
- ****************************************************************************/
-#if !defined(_Ptr_h_)
-#define _Ptr_h_
+#ifndef PTR_H_FBBD7DC3_CA5D_4715_9162_5E4DDA93353F
+#define PTR_H_FBBD7DC3_CA5D_4715_9162_5E4DDA93353F
 
 #include "ts/ink_atomic.h"
 
-////////////////////////////////////////////////////////////////////////
-//
-// class NonAtomicRefCountObj
-// prototypical class for reference counting
-//
-////////////////////////////////////////////////////////////////////////
-class NonAtomicRefCountObj
-{
-public:
-  NonAtomicRefCountObj() : m_refcount(0) { return; }
-  NonAtomicRefCountObj(const NonAtomicRefCountObj &s) : m_refcount(0)
-  {
-    (void)s;
-    return;
-  }
-  virtual ~NonAtomicRefCountObj() { return; }
-  NonAtomicRefCountObj &
-  operator=(const NonAtomicRefCountObj &s)
-  {
-    (void)s;
-    return (*this);
-  }
-
-  int refcount_inc();
-  int refcount_dec();
-  int refcount() const;
-
-  virtual void
-  free()
-  {
-    delete this;
-  }
-
-  volatile int m_refcount;
-};
-
-inline int
-NonAtomicRefCountObj::refcount_inc()
-{
-  return ++m_refcount;
-}
-
-#define NONATOMIC_REF_COUNT_OBJ_REFCOUNT_INC(_x) (_x)->refcount_inc()
-
-inline int
-NonAtomicRefCountObj::refcount_dec()
-{
-  return --m_refcount;
-}
-
-#define NONATOMIC_REF_COUNT_OBJ_REFCOUNT_DEC(_x) (_x)->refcount_dec()
-
-inline int
-NonAtomicRefCountObj::refcount() const
-{
-  return m_refcount;
-}
-
-////////////////////////////////////////////////////////////////////////
-//
-// class NonAtomicPtr
-//
-////////////////////////////////////////////////////////////////////////
-template <class T> class NonAtomicPtr
-{
-public:
-  explicit NonAtomicPtr(T *ptr = 0);
-  NonAtomicPtr(const NonAtomicPtr<T> &);
-  ~NonAtomicPtr();
-
-  NonAtomicPtr<T> &operator=(const NonAtomicPtr<T> &);
-  NonAtomicPtr<T> &operator=(T *);
-
-  void clear();
-
-  operator T *() const { return (m_ptr); }
-  T *operator->() const { return (m_ptr); }
-  T &operator*() const { return (*m_ptr); }
-  int
-  operator==(const T *p)
-  {
-    return (m_ptr == p);
-  }
-  int
-  operator==(const NonAtomicPtr<T> &p)
-  {
-    return (m_ptr == p.m_ptr);
-  }
-  int
-  operator!=(const T *p)
-  {
-    return (m_ptr != p);
-  }
-  int
-  operator!=(const NonAtomicPtr<T> &p)
-  {
-    return (m_ptr != p.m_ptr);
-  }
-
-  NonAtomicRefCountObj *
-  _ptr()
-  {
-    return (NonAtomicRefCountObj *)m_ptr;
-  }
-
-  T *m_ptr;
-};
-
-template <typename T>
-NonAtomicPtr<T>
-make_nonatomic_ptr(T *p)
-{
-  return NonAtomicPtr<T>(p);
-}
-
-////////////////////////////////////////////////////////////////////////
-//
-// inline functions definitions
-//
-////////////////////////////////////////////////////////////////////////
-template <class T> inline NonAtomicPtr<T>::NonAtomicPtr(T *ptr /* = 0 */) : m_ptr(ptr)
-{
-  if (m_ptr)
-    _ptr()->refcount_inc();
-  return;
-}
-
-template <class T> inline NonAtomicPtr<T>::NonAtomicPtr(const NonAtomicPtr<T> &src) : m_ptr(src.m_ptr)
-{
-  if (m_ptr)
-    _ptr()->refcount_inc();
-  return;
-}
-
-template <class T> inline NonAtomicPtr<T>::~NonAtomicPtr()
-{
-  if ((m_ptr) && _ptr()->refcount_dec() == 0) {
-    _ptr()->free();
-  }
-  return;
-}
-
-template <class T>
-inline NonAtomicPtr<T> &
-NonAtomicPtr<T>::operator=(T *p)
-{
-  T *temp_ptr = m_ptr;
-
-  if (m_ptr == p)
-    return (*this);
-
-  m_ptr = p;
-
-  if (m_ptr != 0) {
-    _ptr()->refcount_inc();
-  }
-
-  if ((temp_ptr) && ((NonAtomicRefCountObj *)temp_ptr)->refcount_dec() == 0) {
-    ((NonAtomicRefCountObj *)temp_ptr)->free();
-  }
-
-  return (*this);
-}
-template <class T>
-inline void
-NonAtomicPtr<T>::clear()
-{
-  if (m_ptr) {
-    if (!((NonAtomicRefCountObj *)m_ptr)->refcount_dec())
-      ((NonAtomicRefCountObj *)m_ptr)->free();
-    m_ptr = NULL;
-  }
-}
-template <class T>
-inline NonAtomicPtr<T> &
-NonAtomicPtr<T>::operator=(const NonAtomicPtr<T> &src)
-{
-  return (operator=(src.m_ptr));
-}
-
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //////              ATOMIC VERSIONS
@@ -419,4 +228,4 @@ Ptr<T>::operator=(const Ptr<T> &src)
   return (operator=(src.m_ptr));
 }
 
-#endif
+#endif /* PTR_H_FBBD7DC3_CA5D_4715_9162_5E4DDA93353F */

-- 
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>.