This polishes the RefCount API a bit.

* Shuffle RefCount.h and its unit-tests into src/base/

* Reworks struct Refcountable_ into class LockableObject in its own header file
 + changing the reference counter accessors to a lock()/unlock() names
+ some minor symbol updates of code directly utilizing the RefCountable_ members

With this we can begin the process of replacing our multiple different implementations of the reference-counting pattern using LockableObject.

No code changes have been made. Just symbol polishing.
If there are no objections I will apply this in a day or two.


TODO: Followup stages which can build on this are (in no particular order):
* update the backend of CBDATA to utilize LockableObject for reference tracking * update the HttpMsg locking API to utilize LockableObject for reference tracking
 * replace the HttpMsgPointerT locking API with RefCount<HttpMsg>
 * replace the StoreEntry locking API and move to CbcPointer

I'm sure there are others floating around as well that I have not encountered yet. lock/unlock seems to be a popular operation in the code.

Amos

=== modified file 'src/AccessLogEntry.h'
--- src/AccessLogEntry.h        2012-09-21 14:57:30 +0000
+++ src/AccessLogEntry.h        2012-10-26 09:43:15 +0000
@@ -31,6 +31,7 @@
 #define SQUID_HTTPACCESSLOGENTRY_H
 
 #include "anyp/PortCfg.h"
+#include "base/RefCount.h"
 #include "comm/Connection.h"
 #include "HttpVersion.h"
 #include "HttpRequestMethod.h"
@@ -41,7 +42,6 @@
 #if ICAP_CLIENT
 #include "adaptation/icap/Elements.h"
 #endif
-#include "RefCount.h"
 #if USE_SSL
 #include "ssl/gadgets.h"
 #endif

=== modified file 'src/ClientRequestContext.h'
--- src/ClientRequestContext.h  2012-08-14 11:53:07 +0000
+++ src/ClientRequestContext.h  2012-10-26 10:02:00 +0000
@@ -1,8 +1,8 @@
 #ifndef SQUID_CLIENTREQUESTCONTEXT_H
 #define SQUID_CLIENTREQUESTCONTEXT_H
 
+#include "base/RefCount.h"
 #include "cbdata.h"
-#include "RefCount.h"
 #include "ipcache.h"
 
 #if USE_ADAPTATION

=== modified file 'src/DelayIdComposite.h'
--- src/DelayIdComposite.h      2012-09-01 14:38:36 +0000
+++ src/DelayIdComposite.h      2012-10-26 10:02:22 +0000
@@ -38,8 +38,8 @@
 #define DELAYIDCOMPOSITE_H
 
 #if USE_DELAY_POOLS
+#include "base/RefCount.h"
 #include "fatal.h"
-#include "RefCount.h"
 
 class DeferredRead;
 

=== modified file 'src/DiskIO/DiskDaemon/DiskdFile.cc'
--- src/DiskIO/DiskDaemon/DiskdFile.cc  2012-10-08 07:06:28 +0000
+++ src/DiskIO/DiskDaemon/DiskdFile.cc  2012-10-26 08:42:39 +0000
@@ -386,7 +386,7 @@
     assert (M->requestor);
     ReadRequest::Pointer readRequest = dynamic_cast<ReadRequest 
*>(M->requestor);
     /* remove the free protection */
-    readRequest->RefCountDereference();
+    readRequest->unlock();
 
     if (M->status < 0) {
         ++diskd_stats.read.fail;
@@ -410,7 +410,7 @@
     assert (M->requestor);
     WriteRequest::Pointer writeRequest = dynamic_cast<WriteRequest 
*>(M->requestor);
     /* remove the free protection */
-    writeRequest->RefCountDereference();
+    writeRequest->unlock();
 
     if (M->status < 0) {
         errorOccured = true;

=== modified file 'src/DiskIO/DiskDaemon/DiskdIOStrategy.cc'
--- src/DiskIO/DiskDaemon/DiskdIOStrategy.cc    2012-10-08 07:06:28 +0000
+++ src/DiskIO/DiskDaemon/DiskdIOStrategy.cc    2012-10-26 08:40:15 +0000
@@ -324,7 +324,7 @@
 
     if (M->newstyle) {
         DiskdFile *theFile = (DiskdFile *)M->callback_data;
-        theFile->RefCountDereference();
+        theFile->unlock();
         theFile->completed (M);
     } else
         switch (M->mtype) {
@@ -354,16 +354,16 @@
 }
 
 int
-DiskdIOStrategy::send(int mtype, int id, DiskdFile *theFile, size_t size, 
off_t offset, ssize_t shm_offset, RefCountable_ *requestor)
+DiskdIOStrategy::send(int mtype, int id, DiskdFile *theFile, size_t size, 
off_t offset, ssize_t shm_offset, LockableObject *requestor)
 {
     diomsg M;
     M.callback_data = cbdataReference(theFile);
-    theFile->RefCountReference();
+    theFile->lock();
     M.requestor = requestor;
     M.newstyle = true;
 
     if (requestor)
-        requestor->RefCountReference();
+        requestor->lock();
 
     return SEND(&M, mtype, id, size, offset, shm_offset);
 }

=== modified file 'src/DiskIO/DiskDaemon/DiskdIOStrategy.h'
--- src/DiskIO/DiskDaemon/DiskdIOStrategy.h     2012-09-01 14:38:36 +0000
+++ src/DiskIO/DiskDaemon/DiskdIOStrategy.h     2012-10-26 08:22:22 +0000
@@ -62,7 +62,7 @@
 class DiskFile;
 
 class DiskdFile;
-
+class LockableObject;
 class ReadRequest;
 
 /// \ingroup diskd
@@ -80,8 +80,8 @@
     virtual void init();
     virtual void sync();
     virtual int callback();
-    virtual void statfs(StoreEntry & sentry)const;
-    int send(int mtype, int id, DiskdFile *theFile, size_t size, off_t offset, 
ssize_t shm_offset, RefCountable_ *requestor);
+    virtual void statfs(StoreEntry & sentry) const;
+    int send(int mtype, int id, DiskdFile *theFile, size_t size, off_t offset, 
ssize_t shm_offset, LockableObject *requestor);
 
     /** public for accessing return address's */
     SharedMemory shm;

=== modified file 'src/DiskIO/DiskDaemon/diomsg.h'
--- src/DiskIO/DiskDaemon/diomsg.h      2011-10-30 02:42:27 +0000
+++ src/DiskIO/DiskDaemon/diomsg.h      2012-10-26 08:38:02 +0000
@@ -17,14 +17,14 @@
     _MQD_UNLINK
 };
 
-struct RefCountable_;
+class LockableObject;
 
 struct diomsg {
     mtyp_t mtype;
     int id;
     int seq_no;
     void * callback_data;
-    RefCountable_ * requestor;
+    LockableObject * requestor;
     size_t size;
     off_t offset;
     int status;

=== modified file 'src/DiskIO/DiskFile.h'
--- src/DiskIO/DiskFile.h       2012-09-01 14:38:36 +0000
+++ src/DiskIO/DiskFile.h       2012-10-26 09:44:40 +0000
@@ -31,10 +31,9 @@
 #ifndef SQUID_DISKFILE_H
 #define SQUID_DISKFILE_H
 
+#include "base/RefCount.h"
 #include "typedefs.h"
 
-#include "RefCount.h"
-
 class IORequestor;
 
 class ReadRequest;

=== modified file 'src/DiskIO/DiskIOStrategy.h'
--- src/DiskIO/DiskIOStrategy.h 2012-09-01 14:38:36 +0000
+++ src/DiskIO/DiskIOStrategy.h 2012-10-26 09:45:29 +0000
@@ -31,8 +31,8 @@
 #ifndef SQUID_DISKIOSTRATEGY_H
 #define SQUID_DISKIOSTRATEGY_H
 
+#include "base/RefCount.h"
 #include "Store.h"
-#include "RefCount.h"
 
 class DiskFile;
 

=== modified file 'src/DiskIO/IORequestor.h'
--- src/DiskIO/IORequestor.h    2012-09-01 14:38:36 +0000
+++ src/DiskIO/IORequestor.h    2012-10-26 09:47:26 +0000
@@ -32,7 +32,7 @@
 #ifndef SQUID_IOREQUESTOR_H
 #define SQUID_IOREQUESTOR_H
 
-#include "RefCount.h"
+#include "base/RefCount.h"
 
 class ReadRequest;
 

=== modified file 'src/DiskIO/ReadRequest.h'
--- src/DiskIO/ReadRequest.h    2012-09-01 14:38:36 +0000
+++ src/DiskIO/ReadRequest.h    2012-10-26 09:46:51 +0000
@@ -32,8 +32,8 @@
 #ifndef SQUID_READREQUEST_H
 #define SQUID_READREQUEST_H
 
+#include "base/RefCount.h"
 #include "cbdata.h"
-#include "RefCount.h"
 
 class ReadRequest : public RefCountable
 {

=== modified file 'src/DiskIO/WriteRequest.h'
--- src/DiskIO/WriteRequest.h   2012-09-01 14:38:36 +0000
+++ src/DiskIO/WriteRequest.h   2012-10-26 09:46:15 +0000
@@ -32,8 +32,8 @@
 #ifndef SQUID_WRITEREQUEST_H
 #define SQUID_WRITEREQUEST_H
 
+#include "base/RefCount.h"
 #include "cbdata.h"
-#include "RefCount.h"
 
 class WriteRequest : public RefCountable
 {

=== modified file 'src/MemBlob.cc'
--- src/MemBlob.cc      2012-08-31 16:57:39 +0000
+++ src/MemBlob.cc      2012-10-26 08:10:42 +0000
@@ -142,6 +142,6 @@
     << "mem:" << static_cast<void*>(mem)
     << ",capacity:" << capacity
     << ",size:" << size
-    << ",refs:" << RefCountCount() << "; ";
+    << ",refs:" << LockCount() << "; ";
     return os;
 }

=== modified file 'src/MemBlob.h'
--- src/MemBlob.h       2012-08-28 13:00:30 +0000
+++ src/MemBlob.h       2012-10-26 10:02:59 +0000
@@ -34,8 +34,8 @@
 #define MEMBLOB_DEBUGSECTION 24
 
 #include "base/InstanceId.h"
+#include "base/RefCount.h"
 #include "MemPool.h"
-#include "RefCount.h"
 
 /// Various MemBlob class-wide statistics.
 class MemBlobStats

=== modified file 'src/NullDelayId.h'
--- src/NullDelayId.h   2012-09-01 14:38:36 +0000
+++ src/NullDelayId.h   2012-10-26 10:03:08 +0000
@@ -38,7 +38,7 @@
 #define NULLDELAYID_H
 
 #if USE_DELAY_POOLS
-#include "RefCount.h"
+#include "base/RefCount.h"
 #include "DelayIdComposite.h"
 
 class NullDelayId : public DelayIdComposite

=== modified file 'src/SquidConfig.h'
--- src/SquidConfig.h   2012-10-09 23:15:44 +0000
+++ src/SquidConfig.h   2012-10-26 09:36:56 +0000
@@ -30,13 +30,13 @@
  */
 
 #include "acl/AclAddress.h"
+#include "base/RefCount.h"
 #include "ClientDelayConfig.h"
 #include "DelayConfig.h"
 #include "HelperChildConfig.h"
 #include "HttpHeaderTools.h"
 #include "icmp/IcmpConfig.h"
 #include "ip/Address.h"
-#include "RefCount.h"
 #include "YesNoNone.h"
 
 #if USE_SSL

=== modified file 'src/Store.h'
--- src/Store.h 2012-10-16 00:18:09 +0000
+++ src/Store.h 2012-10-26 09:40:03 +0000
@@ -35,13 +35,13 @@
  \ingroup FileSystems
  */
 
+#include "base/RefCount.h"
 #include "comm/forward.h"
 #include "CommRead.h"
 #include "hash.h"
 #include "HttpReply.h"
 #include "HttpRequestMethod.h"
 #include "Range.h"
-#include "RefCount.h"
 #include "RemovalPolicy.h"
 #include "StoreIOBuffer.h"
 #include "StoreStats.h"

=== modified file 'src/StoreIOState.h'
--- src/StoreIOState.h  2012-10-03 17:32:57 +0000
+++ src/StoreIOState.h  2012-10-26 10:09:07 +0000
@@ -32,8 +32,8 @@
 #ifndef SQUID_STOREIOSTATE_H
 #define SQUID_STOREIOSTATE_H
 
+#include "base/RefCount.h"
 #include "cbdata.h"
-#include "RefCount.h"
 
 class StoreIOState : public RefCountable
 {

=== modified file 'src/StoreSearch.h'
--- src/StoreSearch.h   2012-09-01 14:38:36 +0000
+++ src/StoreSearch.h   2012-10-26 09:44:31 +0000
@@ -31,7 +31,7 @@
 #ifndef SQUID_STORESEARCH_H
 #define SQUID_STORESEARCH_H
 
-#include "RefCount.h"
+#include "base/RefCount.h"
 #include "Store.h"
 
 class StoreSearch : public RefCountable

=== modified file 'src/adaptation/History.h'
--- src/adaptation/History.h    2012-08-28 13:00:30 +0000
+++ src/adaptation/History.h    2012-10-26 10:05:21 +0000
@@ -3,8 +3,8 @@
 
 #include "adaptation/DynamicGroupCfg.h"
 #include "Array.h"
+#include "base/RefCount.h"
 #include "HttpHeader.h"
-#include "RefCount.h"
 #include "SquidString.h"
 
 namespace Adaptation

=== modified file 'src/adaptation/Message.h'
--- src/adaptation/Message.h    2012-10-04 11:10:17 +0000
+++ src/adaptation/Message.h    2012-10-26 10:05:44 +0000
@@ -1,7 +1,7 @@
 #ifndef SQUID__ADAPTATION__MESSAGE_H
 #define SQUID__ADAPTATION__MESSAGE_H
 
-#include "RefCount.h"
+#include "base/RefCount.h"
 
 class HttpMsg;
 class BodyPipe;

=== modified file 'src/adaptation/Service.h'
--- src/adaptation/Service.h    2012-10-04 09:14:06 +0000
+++ src/adaptation/Service.h    2012-10-26 10:05:54 +0000
@@ -2,10 +2,10 @@
 #define SQUID_ADAPTATION__SERVICE_H
 
 #include "SquidString.h"
-#include "RefCount.h"
 #include "adaptation/forward.h"
 #include "adaptation/Elements.h"
 #include "adaptation/ServiceConfig.h"
+#include "base/RefCount.h"
 
 // TODO: Move src/ICAP/ICAPServiceRep.h API comments here and update them
 

=== modified file 'src/adaptation/ServiceConfig.h'
--- src/adaptation/ServiceConfig.h      2011-05-13 10:38:28 +0000
+++ src/adaptation/ServiceConfig.h      2012-10-26 10:05:35 +0000
@@ -2,7 +2,7 @@
 #define SQUID_ADAPTATION__SERVICE_CONFIG_H
 
 #include "SquidString.h"
-#include "RefCount.h"
+#include "base/RefCount.h"
 #include "adaptation/Elements.h"
 
 namespace Adaptation

=== modified file 'src/adaptation/ServiceGroups.h'
--- src/adaptation/ServiceGroups.h      2012-10-04 09:14:06 +0000
+++ src/adaptation/ServiceGroups.h      2012-10-26 10:06:04 +0000
@@ -3,9 +3,9 @@
 
 #include "SquidString.h"
 #include "Array.h"
-#include "RefCount.h"
 #include "adaptation/Elements.h"
 #include "adaptation/forward.h"
+#include "base/RefCount.h"
 
 namespace Adaptation
 {

=== modified file 'src/adaptation/icap/History.h'
--- src/adaptation/icap/History.h       2012-08-14 11:53:07 +0000
+++ src/adaptation/icap/History.h       2012-10-26 10:05:00 +0000
@@ -1,8 +1,8 @@
 #ifndef SQUID_ICAPHISTORY_H
 #define SQUID_ICAPHISTORY_H
 
+#include "base/RefCount.h"
 #include "enums.h"
-#include "RefCount.h"
 #include "SquidString.h"
 
 namespace Adaptation

=== modified file 'src/adaptation/icap/icap_log.h'
--- src/adaptation/icap/icap_log.h      2012-08-14 11:53:07 +0000
+++ src/adaptation/icap/icap_log.h      2012-10-26 10:05:07 +0000
@@ -2,7 +2,7 @@
 #define ICAP_LOG_H_
 
 #include "AccessLogEntry.h"
-#include "RefCount.h"
+#include "base/RefCount.h"
 
 typedef RefCount<AccessLogEntry> AccessLogEntryPointer;
 class AccessLogEntry;

=== modified file 'src/auth/Scheme.h'
--- src/auth/Scheme.h   2012-09-01 14:38:36 +0000
+++ src/auth/Scheme.h   2012-10-26 09:38:55 +0000
@@ -34,7 +34,7 @@
 #if USE_AUTH
 
 #include "Array.h"
-#include "RefCount.h"
+#include "base/RefCount.h"
 
 /**
  \defgroup AuthSchemeAPI       Authentication Scheme API

=== modified file 'src/auth/User.cc'
--- src/auth/User.cc    2012-09-04 09:10:20 +0000
+++ src/auth/User.cc    2012-10-26 08:12:24 +0000
@@ -151,7 +151,7 @@
 Auth::User::~User()
 {
     debugs(29, 5, HERE << "Freeing auth_user '" << this << "'.");
-    assert(RefCountCount() == 0);
+    assert(LockCount() == 0);
 
     /* free cached acl results */
     aclCacheMatchFlush(&proxy_match_cache);
@@ -223,7 +223,7 @@
                auth_user->auth_type << "\n\tUsername: " << username <<
                "\n\texpires: " <<
                (long int) (auth_user->expiretime + ::Config.authenticateTTL) <<
-               "\n\treferences: " << (long int) auth_user->RefCountCount());
+               "\n\treferences: " << auth_user->LockCount());
 
         if (auth_user->expiretime + ::Config.authenticateTTL <= 
current_time.tv_sec) {
             debugs(29, 5, HERE << "Removing user " << username << " from cache 
due to timeout.");

=== modified file 'src/auth/User.h'
--- src/auth/User.h     2012-09-01 14:38:36 +0000
+++ src/auth/User.h     2012-10-26 09:39:50 +0000
@@ -36,9 +36,9 @@
 
 #include "auth/CredentialState.h"
 #include "auth/Type.h"
+#include "base/RefCount.h"
 #include "dlink.h"
 #include "ip/Address.h"
-#include "RefCount.h"
 
 class AuthUserHashPointer;
 class StoreEntry;

=== modified file 'src/auth/UserRequest.cc'
--- src/auth/UserRequest.cc     2012-09-01 14:42:17 +0000
+++ src/auth/UserRequest.cc     2012-10-26 08:11:27 +0000
@@ -117,7 +117,7 @@
 
 Auth::UserRequest::~UserRequest()
 {
-    assert(RefCountCount()==0);
+    assert(LockCount()==0);
     debugs(29, 5, HERE << "freeing request " << this);
 
     if (user() != NULL) {

=== modified file 'src/auth/basic/UserRequest.h'
--- src/auth/basic/UserRequest.h        2012-06-19 23:16:13 +0000
+++ src/auth/basic/UserRequest.h        2012-10-26 08:00:22 +0000
@@ -21,7 +21,7 @@
     MEMPROXY_CLASS(Auth::Basic::UserRequest);
 
     UserRequest() {}
-    virtual ~UserRequest() { assert(RefCountCount()==0); }
+    virtual ~UserRequest() { assert(LockCount()==0); }
 
     virtual int authenticated() const;
     virtual void authenticate(HttpRequest * request, ConnStateData *conn, 
http_hdr_type type);

=== modified file 'src/auth/digest/UserRequest.cc'
--- src/auth/digest/UserRequest.cc      2012-08-31 16:57:39 +0000
+++ src/auth/digest/UserRequest.cc      2012-10-26 08:09:38 +0000
@@ -28,7 +28,7 @@
  */
 Auth::Digest::UserRequest::~UserRequest()
 {
-    assert(RefCountCount()==0);
+    assert(LockCount()==0);
 
     safe_free(nonceb64);
     safe_free(cnonce);

=== modified file 'src/auth/negotiate/UserRequest.cc'
--- src/auth/negotiate/UserRequest.cc   2012-09-19 17:16:56 +0000
+++ src/auth/negotiate/UserRequest.cc   2012-10-26 08:06:07 +0000
@@ -22,7 +22,7 @@
 
 Auth::Negotiate::UserRequest::~UserRequest()
 {
-    assert(RefCountCount()==0);
+    assert(LockCount()==0);
     safe_free(server_blob);
     safe_free(client_blob);
 

=== modified file 'src/auth/ntlm/UserRequest.cc'
--- src/auth/ntlm/UserRequest.cc        2012-09-19 17:16:56 +0000
+++ src/auth/ntlm/UserRequest.cc        2012-10-26 08:05:15 +0000
@@ -19,7 +19,7 @@
 
 Auth::Ntlm::UserRequest::~UserRequest()
 {
-    assert(RefCountCount()==0);
+    assert(LockCount()==0);
     safe_free(server_blob);
     safe_free(client_blob);
 

=== added file 'src/base/LockableObject.h'
--- src/base/LockableObject.h   1970-01-01 00:00:00 +0000
+++ src/base/LockableObject.h   2012-10-26 03:43:24 +0000
@@ -0,0 +1,44 @@
+#ifndef SQUID_SRC_BASE_LOCKABLEOBJECT_H
+#define SQUID_SRC_BASE_LOCKABLEOBJECT_H
+
+/**
+ * Base class for all reference tracking types.
+ * RefCount, CbData, etc
+ *
+ * The objects to be tracked inherit from this and 
+ * construct/destruct/invalidation of the trackign mechanism
+ * use this interface API to maintain the locks.
+ */
+class LockableObject {
+public:
+    LockableObject():count_(0) {}
+
+    virtual ~LockableObject() { assert(count_ == 0); }
+
+    /* Not private, to allow class hierarchies */
+    void lock() const {
+#if REFCOUNT_DEBUG
+        old_debug(0,1)("Incrementing this %p from count %u\n",this,count_);
+#endif
+        ++count_;
+    }
+
+    unsigned unlock() const {
+#if REFCOUNT_DEBUG
+        old_debug(0,1)("Decrementing this %p from count %u\n",this,count_);
+#endif
+        return --count_;
+    }
+
+    unsigned LockCount() const { return count_; } // for debugging only
+
+private:
+    mutable unsigned count_;
+};
+
+// TODO: update all code to use 'Lockable' instead
+#define RefCountable virtual LockableObject
+
+#define Lockable virtual LockableObject
+
+#endif /* SQUID_SRC_BASE_LOCKABLEOBJECT_H */

=== modified file 'src/base/Makefile.am'
--- src/base/Makefile.am        2011-12-04 05:39:39 +0000
+++ src/base/Makefile.am        2012-10-26 10:27:03 +0000
@@ -16,9 +16,24 @@
        TidyPointer.h \
        CbcPointer.h \
        InstanceId.h \
+       LockableObject.h \
        RunnersRegistry.cc \
        RunnersRegistry.h \
        Subscription.h \
        TextException.cc \
        TextException.h \
        StringArea.h
+
+check_PROGRAMS += testRefCount
+
+testRefCount_SOURCES= \
+       LockableObject.h \
+       RefCount.h \
+       testRefCount.cc
+
+testRefCount_LDADD = \
+       libbase.la \
+       $(top_builddir)/lib/libmiscutil.la \
+       $(COMPAT_LIB) \
+       $(XTRA_LIBS)
+

=== renamed file 'include/RefCount.h' => 'src/base/RefCount.h'
--- include/RefCount.h  2012-09-01 14:38:36 +0000
+++ src/base/RefCount.h 2012-10-26 07:51:28 +0000
@@ -33,10 +33,19 @@
 #ifndef SQUID_REFCOUNT_H_
 #define SQUID_REFCOUNT_H_
 
+// reference counting requires the LockableObject API on base classes
+#include "base/LockableObject.h"
+
 #if HAVE_IOSTREAM
 #include <iostream>
 #endif
 
+/**
+ * Template for Reference Counting pointers.
+ *
+ * Objects of type 'C' must inherit from 'Lockable' in base/LockableObject.h
+ * which provides the locking interface used by reference counting.
+ */
 template <class C>
 class RefCount
 {
@@ -90,54 +99,24 @@
         C const (*tempP_) (p_);
         p_ = newP;
 
-        if (tempP_ && tempP_->RefCountDereference() == 0)
+        if (tempP_ && tempP_->unlock() == 0)
             delete tempP_;
     }
 
     void reference (const RefCount& p) {
         if (p.p_)
-            p.p_->RefCountReference();
+            p.p_->lock();
     }
 
     C const *p_;
 
 };
 
-struct RefCountable_ {
-    RefCountable_():count_(0) {}
-
-    virtual ~RefCountable_() { assert(count_ == 0); }
-
-    /* Not private, to allow class hierarchies */
-    void RefCountReference() const {
-#if REFCOUNT_DEBUG
-        old_debug(0,1)("Incrementing this %p from count %u\n",this,count_);
-#endif
-
-        ++count_;
-    }
-
-    unsigned RefCountDereference() const {
-#if REFCOUNT_DEBUG
-        old_debug(0,1)("Decrementing this %p from count %u\n",this,count_);
-#endif
-
-        return --count_;
-    }
-
-    unsigned RefCountCount() const { return count_; } // for debugging only
-
-private:
-    mutable unsigned count_;
-};
-
-#define RefCountable virtual RefCountable_
-
 template <class C>
 inline std::ostream &operator <<(std::ostream &os, const RefCount<C> &p)
 {
     if (p != NULL)
-        return os << p.getRaw() << '*' << p->RefCountCount();
+        return os << p.getRaw() << '*' << p->LockCount();
     else
         return os << "NULL";
 }

=== renamed file 'test-suite/refcount.cc' => 'src/base/testRefCount.cc'
--- test-suite/refcount.cc      2012-09-01 14:38:36 +0000
+++ src/base/testRefCount.cc    2012-10-26 09:08:12 +0000
@@ -1,4 +1,3 @@
-
 /*
  * DEBUG: section --    Refcount allocator
  * AUTHOR:  Robert Collins
@@ -32,7 +31,9 @@
  */
 
 #include "squid.h"
-#include "RefCount.h"
+#include "base/RefCount.h"
+
+// XXX: upgrade these tests to CPPUnit testing framework
 
 class _ToRefCount :public RefCountable
 {

=== modified file 'src/clientStream.h'
--- src/clientStream.h  2012-10-03 17:32:57 +0000
+++ src/clientStream.h  2012-10-26 10:01:15 +0000
@@ -32,8 +32,8 @@
 #ifndef SQUID_CLIENTSTREAM_H
 #define SQUID_CLIENTSTREAM_H
 
+#include "base/RefCount.h"
 #include "dlink.h"
-#include "RefCount.h"
 #include "StoreIOBuffer.h"
 
 /**
@@ -96,7 +96,7 @@
  */
 
 /// \ingroup ClientStreamAPI
-typedef RefCount<RefCountable_> ClientStreamData;
+typedef RefCount<LockableObject> ClientStreamData;
 
 class clientStreamNode;
 class ClientHttpRequest;

=== modified file 'src/client_side.h'
--- src/client_side.h   2012-10-04 00:23:44 +0000
+++ src/client_side.h   2012-10-26 09:40:52 +0000
@@ -34,13 +34,13 @@
 #define SQUID_CLIENTSIDE_H
 
 #include "base/AsyncJob.h"
+#include "base/RefCount.h"
 #include "BodyPipe.h"
 #include "comm.h"
 #include "CommCalls.h"
 #include "HttpRequest.h"
 #include "HttpControlMsg.h"
 #include "HttpParser.h"
-#include "RefCount.h"
 #include "StoreIOBuffer.h"
 #if USE_AUTH
 #include "auth/UserRequest.h"

=== modified file 'src/client_side_reply.h'
--- src/client_side_reply.h     2012-09-10 12:49:35 +0000
+++ src/client_side_reply.h     2012-10-26 10:06:15 +0000
@@ -31,10 +31,10 @@
 #ifndef SQUID_CLIENTSIDEREPLY_H
 #define SQUID_CLIENTSIDEREPLY_H
 
+#include "base/RefCount.h"
 #include "client_side_request.h"
 #include "clientStream.h"
 #include "HttpHeader.h"
-#include "RefCount.h"
 #include "RequestFlags.h"
 #include "StoreClient.h"
 

=== modified file 'src/comm/Connection.h'
--- src/comm/Connection.h       2012-09-04 14:38:44 +0000
+++ src/comm/Connection.h       2012-10-26 09:35:54 +0000
@@ -37,12 +37,12 @@
 #ifndef _SQUIDCONNECTIONDETAIL_H_
 #define _SQUIDCONNECTIONDETAIL_H_
 
+#include "base/RefCount.h"
 #include "comm/forward.h"
 #include "defines.h"
 #include "hier_code.h"
 #include "ip/Address.h"
 #include "MemPool.h"
-#include "RefCount.h"
 #include "typedefs.h"
 #if USE_SQUID_EUI
 #include "eui/Eui48.h"

=== modified file 'src/comm/forward.h'
--- src/comm/forward.h  2011-06-18 00:12:51 +0000
+++ src/comm/forward.h  2012-10-26 09:35:28 +0000
@@ -2,7 +2,7 @@
 #define _SQUID_COMM_FORWARD_H
 
 #include "Array.h"
-#include "RefCount.h"
+#include "base/RefCount.h"
 
 namespace Comm
 {

=== modified file 'src/esi/Element.h'
--- src/esi/Element.h   2012-09-01 14:38:36 +0000
+++ src/esi/Element.h   2012-10-26 10:06:22 +0000
@@ -31,9 +31,9 @@
 #ifndef SQUID_ESIELEMENT_H
 #define SQUID_ESIELEMENT_H
 
+#include "base/RefCount.h"
 #include "Debug.h"
 #include "esi/Segment.h"
-#include "RefCount.h"
 
 typedef enum {
     ESI_PROCESS_COMPLETE = 0,

=== modified file 'src/esi/Parser.h'
--- src/esi/Parser.h    2012-09-01 14:38:36 +0000
+++ src/esi/Parser.h    2012-10-26 10:06:35 +0000
@@ -40,8 +40,7 @@
     virtual ~ESIParserClient() {};
 };
 
-/* for RefCountable */
-#include "RefCount.h"
+#include "base/RefCount.h"
 
 class ESIParser : public RefCountable
 {

=== modified file 'src/esi/Segment.h'
--- src/esi/Segment.h   2012-09-21 14:57:30 +0000
+++ src/esi/Segment.h   2012-10-26 10:06:44 +0000
@@ -35,9 +35,9 @@
  * or perhaps use membuffers here?
  */
 
+#include "base/RefCount.h"
 #include "cbdata.h"
 #include "defines.h"
-#include "RefCount.h"
 #include "SquidString.h"
 
 class ESISegment : public RefCountable

=== modified file 'src/format/Format.h'
--- src/format/Format.h 2012-07-17 14:25:06 +0000
+++ src/format/Format.h 2012-10-26 09:36:45 +0000
@@ -1,7 +1,7 @@
 #ifndef _SQUID_FORMAT_FORMAT_H
 #define _SQUID_FORMAT_FORMAT_H
 
-#include "RefCount.h"
+#include "base/RefCount.h"
 /*
  * Squid configuration allows users to define custom formats in
  * several components.

=== modified file 'src/forward.h'
--- src/forward.h       2012-09-21 14:57:30 +0000
+++ src/forward.h       2012-10-26 09:41:24 +0000
@@ -2,13 +2,13 @@
 #define SQUID_FORWARD_H
 
 #include "Array.h"
+#include "base/RefCount.h"
 #include "comm.h"
 #include "comm/Connection.h"
 #include "err_type.h"
 #include "fde.h"
 #include "HttpStatusCode.h"
 #include "ip/Address.h"
-#include "RefCount.h"
 
 /* forward decls */
 

=== modified file 'src/fs/rock/RockSwapDir.cc'
--- src/fs/rock/RockSwapDir.cc  2012-10-16 00:18:09 +0000
+++ src/fs/rock/RockSwapDir.cc  2012-10-26 10:11:37 +0000
@@ -217,7 +217,7 @@
 
     // XXX: SwapDirs aren't refcounted. We make IORequestor calls, which
     // are refcounted. We up our count once to avoid implicit delete's.
-    RefCountReference();
+    lock();
 
     Must(!map);
     map = new DirMap(path);

=== modified file 'src/fs/ufs/RebuildState.h'
--- src/fs/ufs/RebuildState.h   2012-09-06 14:22:03 +0000
+++ src/fs/ufs/RebuildState.h   2012-10-26 09:48:39 +0000
@@ -30,7 +30,7 @@
 #ifndef SQUID_FS_UFS_REBUILDSTATE_H
 #define SQUID_FS_UFS_REBUILDSTATE_H
 
-#include "RefCount.h"
+#include "base/RefCount.h"
 #include "UFSSwapDir.h"
 #include "UFSSwapLogParser.h"
 #include "store_rebuild.h"

=== modified file 'src/ipc/Request.h'
--- src/ipc/Request.h   2012-09-01 14:38:36 +0000
+++ src/ipc/Request.h   2012-10-26 09:56:41 +0000
@@ -6,8 +6,8 @@
 #ifndef SQUID_IPC_REQUEST_H
 #define SQUID_IPC_REQUEST_H
 
+#include "base/RefCount.h"
 #include "ipc/forward.h"
-#include "RefCount.h"
 
 namespace Ipc
 {

=== modified file 'src/ipc/Response.h'
--- src/ipc/Response.h  2012-09-01 14:38:36 +0000
+++ src/ipc/Response.h  2012-10-26 09:57:16 +0000
@@ -6,8 +6,8 @@
 #ifndef SQUID_IPC_RESPONSE_H
 #define SQUID_IPC_RESPONSE_H
 
+#include "base/RefCount.h"
 #include "ipc/forward.h"
-#include "RefCount.h"
 
 namespace Ipc
 {

=== modified file 'src/ipc/mem/Pointer.h'
--- src/ipc/mem/Pointer.h       2012-09-01 14:38:36 +0000
+++ src/ipc/mem/Pointer.h       2012-10-26 09:45:11 +0000
@@ -4,9 +4,9 @@
 #ifndef SQUID_IPC_MEM_POINTER_H
 #define SQUID_IPC_MEM_POINTER_H
 
+#include "base/RefCount.h"
 #include "base/TextException.h"
 #include "ipc/mem/Segment.h"
-#include "RefCount.h"
 
 namespace Ipc
 {

=== modified file 'src/log/Formats.h'
--- src/log/Formats.h   2012-09-21 09:49:04 +0000
+++ src/log/Formats.h   2012-10-26 09:54:42 +0000
@@ -2,7 +2,7 @@
 #define _SQUID_LOG_FORMATS_H
 
 #include "AccessLogEntry.h"
-#include "RefCount.h"
+#include "base/RefCount.h"
 
 typedef RefCount<AccessLogEntry> AccessLogEntryPointer;
 class AccessLogEntry;

=== modified file 'src/mgr/QueryParam.h'
--- src/mgr/QueryParam.h        2012-09-01 14:38:36 +0000
+++ src/mgr/QueryParam.h        2012-10-26 09:56:54 +0000
@@ -6,8 +6,8 @@
 #ifndef SQUID_MGR_QUERY_PARAM_H
 #define SQUID_MGR_QUERY_PARAM_H
 
+#include "base/RefCount.h"
 #include "ipc/forward.h"
-#include "RefCount.h"
 
 namespace Mgr
 {

=== modified file 'src/mgr/forward.h'
--- src/mgr/forward.h   2012-09-01 14:38:36 +0000
+++ src/mgr/forward.h   2012-10-26 09:38:44 +0000
@@ -6,7 +6,7 @@
 #ifndef SQUID_MGR_FORWARD_H
 #define SQUID_MGR_FORWARD_H
 
-#include "RefCount.h"
+#include "base/RefCount.h"
 
 namespace Mgr
 {

=== modified file 'src/ssl/ErrorDetailManager.h'
--- src/ssl/ErrorDetailManager.h        2012-08-28 13:00:30 +0000
+++ src/ssl/ErrorDetailManager.h        2012-10-26 10:06:56 +0000
@@ -1,9 +1,9 @@
 #ifndef _SQUID_SSL_ERRORDETAILMANAGER_H
 #define _SQUID_SSL_ERRORDETAILMANAGER_H
 
+#include "base/RefCount.h"
 #include "ssl/gadgets.h"
 #include "ssl/support.h"
-#include "RefCount.h"
 #include "SquidString.h"
 
 #if HAVE_MAP

=== modified file 'test-suite/Makefile.am'
--- test-suite/Makefile.am      2012-10-05 13:10:15 +0000
+++ test-suite/Makefile.am      2012-10-26 09:08:57 +0000
@@ -30,7 +30,6 @@
        syntheticoperators \
        VirtualDeleteOperator \
        StackTest \
-       refcount\
        splay\
        MemPoolTest\
        mem_node_test\
@@ -43,7 +42,6 @@
                MemPoolTest\
                mem_node_test\
                mem_hdr_test \
-               refcount\
                splay \
                StackTest \
                syntheticoperators \
@@ -86,8 +84,6 @@
 
 MemPoolTest_SOURCES = MemPoolTest.cc
 
-refcount_SOURCES = refcount.cc
-
 splay_SOURCES = splay.cc
 
 StackTest_SOURCES = StackTest.cc $(DEBUG_SOURCE)

Reply via email to