]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Syntax glue to get the MemPool API back in shape.
authorhno <>
Mon, 4 Sep 2006 03:05:19 +0000 (03:05 +0000)
committerhno <>
Mon, 4 Sep 2006 03:05:19 +0000 (03:05 +0000)
Standalone pool:
  MemAllocator *pool = memPoolCreate(name, size)

Pooled class just as before;

class XXX {
public:
  MEMPROXY_CLASS(XXX)
  ...
}

MEMPROXY_CLASS_INLINE(XXX)

The other MemAllocator derived classes is considered private and should
not be used outside MemPool.cc

17 files changed:
include/MemPool.h
src/ACLStrategised.h
src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc
src/DiskIO/DiskThreads/aiops.cc
src/Store.h
src/auth/digest/auth_digest.cc
src/cbdata.cc
src/comm.cc
src/fs/coss/StoreFScoss.cc
src/htcp.cc
src/mem.cc
src/pconn.cc
src/repl/lru/store_repl_lru.cc
src/store.cc
src/tools.cc
test-suite/MemPoolTest.cc
test-suite/test_tools.cc

index b1f6218d94eafcbf4d2a99e255a7d9367109921e..74dfd595be9409b2f655a521214d69c211496189 100644 (file)
@@ -110,6 +110,7 @@ public:
     virtual char const *objectType() const;
     virtual size_t objectSize() const = 0;
     int inUseCount();
+    virtual void setChunkSize(size_t chunksize) {}
 private:
     const char *label;
 };
@@ -293,6 +294,8 @@ struct _MemPoolGlobalStats
 
 #define SIZEOF_CHUNK  ( ( sizeof(MemChunk) + sizeof(double) -1) / sizeof(double) ) * sizeof(double);
 
+#define memPoolCreate MemPools::GetInstance().create
+
 /* Allocator API */
 extern MemPoolIterator * memPoolIterate(void);
 extern MemImplementingAllocator * memPoolIterateNext(MemPoolIterator * iter);
index 8bdbc69c12541d889a392f0423b64ccbf28659fd..e0ef5bb2b4c983660932118b52f842795c7bec7c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ACLStrategised.h,v 1.10 2005/05/08 06:36:45 hno Exp $
+ * $Id: ACLStrategised.h,v 1.11 2006/09/03 21:05:20 hno Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -89,7 +89,7 @@ ACLStrategised<MatchType>::operator new (size_t byteCount)
     assert (byteCount == sizeof (ACLStrategised<MatchType>));
 
     if (!Pool)
-        Pool = MemPools::GetInstance().create("ACLStrategised", sizeof (ACLStrategised<MatchType>));
+        Pool = memPoolCreate("ACLStrategised", sizeof (ACLStrategised<MatchType>));
 
     return Pool->alloc();
 }
index 6d7f42c997cdaacbde0ac325eca5db4fe88f3ec7..f06585af3b8bb06328d0c1dfacd18bc9a5fd327e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: DiskThreadsIOStrategy.cc,v 1.8 2006/09/03 04:12:00 hno Exp $
+ * $Id: DiskThreadsIOStrategy.cc,v 1.9 2006/09/03 21:05:20 hno Exp $
  *
  * DEBUG: section 79    Squid-side Disk I/O functions.
  * AUTHOR: Robert Collins
@@ -49,7 +49,7 @@ DiskThreadsIOStrategy::init(void)
     if (initialised)
         return;
 
-    squidaio_ctrl_pool = MemPools::GetInstance().create("aio_ctrl", sizeof(squidaio_ctrl_t));
+    squidaio_ctrl_pool = memPoolCreate("aio_ctrl", sizeof(squidaio_ctrl_t));
 
     initialised = true;
 
index 314ec65e6b5ce158d56c1f326a37fdcca6b8f27f..baeb3e2935b614c636ccd86d05d99ef54f23af78 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: aiops.cc,v 1.11 2006/09/03 04:12:01 hno Exp $
+ * $Id: aiops.cc,v 1.12 2006/09/03 21:05:20 hno Exp $
  *
  * DEBUG: section 43    AIOPS
  * AUTHOR: Stewart Forster <slf@connect.com.au>
@@ -323,7 +323,7 @@ squidaio_init(void)
     done_queue.blocked = 0;
 
     /* Create threads and get them to sit in their wait loop */
-    squidaio_thread_pool = MemPools::GetInstance().create("aio_thread", sizeof(squidaio_thread_t));
+    squidaio_thread_pool = memPoolCreate("aio_thread", sizeof(squidaio_thread_t));
 
     assert(NUMTHREADS);
 
@@ -343,17 +343,17 @@ squidaio_init(void)
     }
 
     /* Create request pool */
-    squidaio_request_pool = MemPools::GetInstance().create("aio_request", sizeof(squidaio_request_t));
+    squidaio_request_pool = memPoolCreate("aio_request", sizeof(squidaio_request_t));
 
-    squidaio_large_bufs = MemPools::GetInstance().create("squidaio_large_bufs", AIO_LARGE_BUFS);
+    squidaio_large_bufs = memPoolCreate("squidaio_large_bufs", AIO_LARGE_BUFS);
 
-    squidaio_medium_bufs = MemPools::GetInstance().create("squidaio_medium_bufs", AIO_MEDIUM_BUFS);
+    squidaio_medium_bufs = memPoolCreate("squidaio_medium_bufs", AIO_MEDIUM_BUFS);
 
-    squidaio_small_bufs = MemPools::GetInstance().create("squidaio_small_bufs", AIO_SMALL_BUFS);
+    squidaio_small_bufs = memPoolCreate("squidaio_small_bufs", AIO_SMALL_BUFS);
 
-    squidaio_tiny_bufs = MemPools::GetInstance().create("squidaio_tiny_bufs", AIO_TINY_BUFS);
+    squidaio_tiny_bufs = memPoolCreate("squidaio_tiny_bufs", AIO_TINY_BUFS);
 
-    squidaio_micro_bufs = MemPools::GetInstance().create("squidaio_micro_bufs", AIO_MICRO_BUFS);
+    squidaio_micro_bufs = memPoolCreate("squidaio_micro_bufs", AIO_MICRO_BUFS);
 
     squidaio_initialised = 1;
 }
index 008ad74affaa407d37d0ae455b44904c49105733..d017e10bdf3c2b2bd993d9c04d3e660f9af1083e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: Store.h,v 1.25 2006/08/21 00:50:41 robertc Exp $
+ * $Id: Store.h,v 1.26 2006/09/03 21:05:20 hno Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -157,7 +157,7 @@ public:
     virtual void release();
 
 private:
-    static MemImplementingAllocator *pool;
+    static MemAllocator *pool;
 
     bool validLength() const;
 };
index 47c1078475114660c9ae7c6590b95a3732bb50fc..d5e8bbf58e59328eaafad54913cead4a13f31acc 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: auth_digest.cc,v 1.49 2006/09/03 04:12:01 hno Exp $
+ * $Id: auth_digest.cc,v 1.50 2006/09/03 21:05:20 hno Exp $
  *
  * DEBUG: section 29    Authenticator
  * AUTHOR: Robert Collins
@@ -201,7 +201,7 @@ static void
 authenticateDigestNonceSetup(void)
 {
     if (!digest_nonce_pool)
-        digest_nonce_pool = MemPools::GetInstance().create("Digest Scheme nonce's", sizeof(digest_nonce_h));
+        digest_nonce_pool = memPoolCreate("Digest Scheme nonce's", sizeof(digest_nonce_h));
 
     if (!digest_nonce_cache) {
         digest_nonce_cache = hash_create((HASHCMP *) strcmp, 7921, hash_string);
index 5e97034dd0157f6c34e98eab2de09a92eafea29d..037597892390f0fa39aeeb5bab562e3a6f372c40 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cbdata.cc,v 1.74 2006/09/03 05:29:44 hno Exp $
+ * $Id: cbdata.cc,v 1.75 2006/09/03 21:05:20 hno Exp $
  *
  * DEBUG: section 45    Callback Data Registry
  * ORIGINAL AUTHOR: Duane Wessels
@@ -238,7 +238,7 @@ cbdataInternalInitType(cbdata_type type, const char *name, int size, FREE * free
     size += cbdata::Offset;
 #endif
 
-    cbdata_index[type].pool = MemPools::GetInstance().create(label, size);
+    cbdata_index[type].pool = memPoolCreate(label, size);
 
     cbdata_index[type].free_func = free_func;
 
index 5e92d8aa7c486e45b60904ecdf8fe50b7ff91f00..b9f23393a53b6afaa55bf0524c59391f95b52c90 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm.cc,v 1.422 2006/09/02 10:39:53 adrian Exp $
+ * $Id: comm.cc,v 1.423 2006/09/03 21:05:20 hno Exp $
  *
  * DEBUG: section 5     Socket Functions
  * AUTHOR: Harvest Derived
@@ -2003,9 +2003,9 @@ comm_init(void) {
      * Since Squid_MaxFD can be as high as several thousand, don't waste them */
     RESERVED_FD = XMIN(100, Squid_MaxFD / 4);
 
-    comm_write_pool = MemPools::GetInstance().create("CommWriteStateData", sizeof(CommWriteStateData));
+    comm_write_pool = memPoolCreate("CommWriteStateData", sizeof(CommWriteStateData));
 
-    conn_close_pool = MemPools::GetInstance().create("close_handler", sizeof(close_handler));
+    conn_close_pool = memPoolCreate("close_handler", sizeof(close_handler));
 }
 
 /* Write to FD. */
index 2a0ed9771f9cd9e8989937f85f7fcdb057053262..74c1b5485b1a4abae506fd342f8956b14e89f2b7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: StoreFScoss.cc,v 1.6 2006/09/03 04:12:02 hno Exp $
+ * $Id: StoreFScoss.cc,v 1.7 2006/09/03 21:05:21 hno Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Robert Collins
@@ -79,7 +79,7 @@ StoreFScoss::setup()
 {
     assert(!initialised);
 
-    coss_index_pool = MemPools::GetInstance().create("COSS index data", sizeof(CossIndexNode));
+    coss_index_pool = memPoolCreate("COSS index data", sizeof(CossIndexNode));
     initialised = true;
 }
 
index 2adcb279a862fb0893727f22024adbcd80156203..ce1600d7d5f8fa606d8f0819d36fde7bd94bb176 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: htcp.cc,v 1.69 2006/08/25 18:53:35 serassio Exp $
+ * $Id: htcp.cc,v 1.70 2006/09/03 21:05:20 hno Exp $
  *
  * DEBUG: section 31    Hypertext Caching Protocol
  * AUTHOR: Duane Wesssels
@@ -1555,7 +1555,7 @@ htcpInit(void)
     }
 
     if (!htcpDetailPool) {
-        htcpDetailPool = MemPools::GetInstance().create("htcpDetail", sizeof(htcpDetail));
+        htcpDetailPool = memPoolCreate("htcpDetail", sizeof(htcpDetail));
     }
 }
 
index 0fb9a568f01d4fd85fd0a05e4820919fe5b1f847..1b4ec8bf88743a970cce725174a2f420647f67cd 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: mem.cc,v 1.100 2006/09/03 04:09:36 hno Exp $
+ * $Id: mem.cc,v 1.101 2006/09/03 21:05:20 hno Exp $
  *
  * DEBUG: section 13    High Level Memory Pool Management
  * AUTHOR: Harvest Derived
@@ -53,7 +53,7 @@
 static void memStringStats(std::ostream &);
 
 /* module locals */
-static MemImplementingAllocator *MemPools[MEM_MAX];
+static MemAllocator *MemPools[MEM_MAX];
 static double xm_time = 0;
 static double xm_deltat = 0;
 
@@ -169,7 +169,7 @@ memDataInit(mem_type type, const char *name, size_t size, int max_pages_notused)
 {
     assert(name && size);
     assert(MemPools[type] == NULL);
-    MemPools[type] = MemPools::GetInstance().create(name, size);
+    MemPools[type] = memPoolCreate(name, size);
 }
 
 
@@ -415,7 +415,7 @@ Mem::Init(void)
     /* init string pools */
 
     for (i = 0; i < mem_str_pool_count; i++) {
-        StrPools[i].pool = MemPools::GetInstance().create(StrPoolsAttrs[i].name, StrPoolsAttrs[i].obj_size);
+        StrPools[i].pool = memPoolCreate(StrPoolsAttrs[i].name, StrPoolsAttrs[i].obj_size);
 
         if (StrPools[i].pool->objectSize() != StrPoolsAttrs[i].obj_size)
             debugs(13, 1, "Notice: " << StrPoolsAttrs[i].name << " is " << StrPools[i].pool->objectSize() << " bytes instead of requested " << StrPoolsAttrs[i].obj_size << " bytes");
index 12da503f424515a560e18cbfac7af4fd67d38685..39715a2a6e7ddafbcd5d8d1400941e391991dab7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: pconn.cc,v 1.46 2006/05/29 00:15:02 robertc Exp $
+ * $Id: pconn.cc,v 1.47 2006/09/03 21:05:20 hno Exp $
  *
  * DEBUG: section 48    Persistent Connections
  * AUTHOR: Duane Wessels
@@ -303,7 +303,7 @@ PconnPool::count(int uses)
 PconnModule::PconnModule() : pools(NULL), poolCount(0)
 {
     pools = (PconnPool **) xcalloc(MAX_NUM_PCONN_POOLS, sizeof(*pools));
-    pconn_fds_pool = MemPools::GetInstance().create("pconn_fds", PCONN_FDS_SZ * sizeof(int));
+    pconn_fds_pool = memPoolCreate("pconn_fds", PCONN_FDS_SZ * sizeof(int));
     debug(48, 0) ("persistent connection module initialized\n");
 }
 
index a93d188b4fcaab1012fbbf8ea930930db36b8d45..dcd1059b1830035370f04071bc3f6d93d8cd8fe0 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_repl_lru.cc,v 1.19 2006/09/03 04:12:04 hno Exp $
+ * $Id: store_repl_lru.cc,v 1.20 2006/09/03 21:05:21 hno Exp $
  *
  * DEBUG: section ?     LRU Removal policy
  * AUTHOR: Henrik Nordstrom
@@ -97,7 +97,7 @@ struct _LruNode
     dlink_node node;
 };
 
-static MemImplementingAllocator *lru_node_pool = NULL;
+static MemAllocator *lru_node_pool = NULL;
 static int nr_lru_policies = 0;
 
 static void
@@ -334,7 +334,7 @@ createRemovalPolicy_lru(wordlist * args)
 
     if (!lru_node_pool) {
         /* Must be chunked */
-        lru_node_pool = MemPools::GetInstance().create("LRU policy node", sizeof(LruNode));
+        lru_node_pool = memPoolCreate("LRU policy node", sizeof(LruNode));
         lru_node_pool->setChunkSize(512 * 1024);
     }
 
index 647f7a6446510c76798f01d4f237a5242333ecd6..473b5435561dab31b08d511e9f71b24c23ec350d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.599 2006/09/03 04:09:48 robertc Exp $
+ * $Id: store.cc,v 1.600 2006/09/03 21:05:20 hno Exp $
  *
  * DEBUG: section 20    Storage Manager
  * AUTHOR: Harvest Derived
@@ -117,7 +117,7 @@ static EVH storeLateRelease;
  * local variables
  */
 static Stack<StoreEntry*> LateReleaseStack;
-MemImplementingAllocator *StoreEntry::pool = NULL;
+MemAllocator *StoreEntry::pool = NULL;
 
 StorePointer Store::CurrentRoot = NULL;
 
@@ -164,7 +164,7 @@ StoreEntry::operator new (size_t bytecount)
     assert (bytecount == sizeof (StoreEntry));
 
     if (!pool) {
-        pool = MemPools::GetInstance().create ("StoreEntry", bytecount);
+        pool = memPoolCreate ("StoreEntry", bytecount);
         pool->setChunkSize(2048 * 1024);
     }
 
index cd6b3f36ec85f545e07163e576cbd7436ec2aa56..b3faeb55ae11032b86c43c0567ab53328789fd01 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tools.cc,v 1.269 2006/08/19 12:31:21 robertc Exp $
+ * $Id: tools.cc,v 1.270 2006/09/03 21:05:20 hno Exp $
  *
  * DEBUG: section 21    Misc Functions
  * AUTHOR: Harvest Derived
@@ -1038,7 +1038,7 @@ dlink_node *
 dlinkNodeNew()
 {
     if (dlink_node_pool == NULL)
-        dlink_node_pool = MemPools::GetInstance().create("Dlink list nodes", sizeof(dlink_node));
+        dlink_node_pool = memPoolCreate("Dlink list nodes", sizeof(dlink_node));
 
     /* where should we call delete dlink_node_pool;dlink_node_pool = NULL; */
     return (dlink_node *)dlink_node_pool->alloc();
index 74efcfef0d7f6f4957614d281e0110518e2c8599..72163e295554bd33c58aebbe49a08a359d17ef8f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: MemPoolTest.cc,v 1.5 2006/09/03 07:25:13 robertc Exp $
+ * $Id: MemPoolTest.cc,v 1.6 2006/09/03 21:05:22 hno Exp $
  *
  * AUTHOR: Robert Collins
  *
@@ -52,15 +52,15 @@ private:
          public:
                  int aValue;
   };
-  static MemImplementingAllocator *Pool;
+  static MemAllocator *Pool;
 };
-MemImplementingAllocator *MemPoolTest::Pool = NULL;
+MemAllocator *MemPoolTest::Pool = NULL;
 
 void
 MemPoolTest::run()
 {
     assert (Pool == NULL);
-    Pool = MemPools::GetInstance().create("Test Pool", sizeof(SomethingToAlloc));
+    Pool = memPoolCreate("Test Pool", sizeof(SomethingToAlloc));
     assert (Pool);
     SomethingToAlloc *something = static_cast<SomethingToAlloc *>(Pool->alloc());
     assert (something);
index 1e26f60f7ca902cae872860d4055ccfb7a77eb3f..f4a62191b71992de44c87a755dacc7c7da8fc736 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: test_tools.cc,v 1.8 2006/08/12 01:43:12 robertc Exp $
+ * $Id: test_tools.cc,v 1.9 2006/09/03 21:05:22 hno Exp $
  *
  * AUTHOR: Robert Collins
  *
@@ -177,12 +177,12 @@ Debug::finishDebug() {
 
 std::ostringstream *Debug::CurrentDebug (NULL);
 
-MemImplementingAllocator *dlink_node_pool = NULL;
+MemAllocator *dlink_node_pool = NULL;
 
 dlink_node *
 dlinkNodeNew() {
     if (dlink_node_pool == NULL)
-        dlink_node_pool = MemPools::GetInstance().create("Dlink list nodes", sizeof(dlink_node));
+        dlink_node_pool = memPoolCreate("Dlink list nodes", sizeof(dlink_node));
 
     /* where should we call memPoolDestroy(dlink_node_pool); */
     return static_cast<dlink_node *>(dlink_node_pool->alloc());