From: hno <> Date: Mon, 4 Sep 2006 03:05:19 +0000 (+0000) Subject: Syntax glue to get the MemPool API back in shape. X-Git-Tag: SQUID_3_0_PRE5~113 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04eb06897f633cf11414385f2483880d5cb3e3ac;p=thirdparty%2Fsquid.git Syntax glue to get the MemPool API back in shape. 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 --- diff --git a/include/MemPool.h b/include/MemPool.h index b1f6218d94..74dfd595be 100644 --- a/include/MemPool.h +++ b/include/MemPool.h @@ -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); diff --git a/src/ACLStrategised.h b/src/ACLStrategised.h index 8bdbc69c12..e0ef5bb2b4 100644 --- a/src/ACLStrategised.h +++ b/src/ACLStrategised.h @@ -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::operator new (size_t byteCount) assert (byteCount == sizeof (ACLStrategised)); if (!Pool) - Pool = MemPools::GetInstance().create("ACLStrategised", sizeof (ACLStrategised)); + Pool = memPoolCreate("ACLStrategised", sizeof (ACLStrategised)); return Pool->alloc(); } diff --git a/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc b/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc index 6d7f42c997..f06585af3b 100644 --- a/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc +++ b/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc @@ -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; diff --git a/src/DiskIO/DiskThreads/aiops.cc b/src/DiskIO/DiskThreads/aiops.cc index 314ec65e6b..baeb3e2935 100644 --- a/src/DiskIO/DiskThreads/aiops.cc +++ b/src/DiskIO/DiskThreads/aiops.cc @@ -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 @@ -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; } diff --git a/src/Store.h b/src/Store.h index 008ad74aff..d017e10bdf 100644 --- a/src/Store.h +++ b/src/Store.h @@ -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; }; diff --git a/src/auth/digest/auth_digest.cc b/src/auth/digest/auth_digest.cc index 47c1078475..d5e8bbf58e 100644 --- a/src/auth/digest/auth_digest.cc +++ b/src/auth/digest/auth_digest.cc @@ -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); diff --git a/src/cbdata.cc b/src/cbdata.cc index 5e97034dd0..0375978923 100644 --- a/src/cbdata.cc +++ b/src/cbdata.cc @@ -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; diff --git a/src/comm.cc b/src/comm.cc index 5e92d8aa7c..b9f23393a5 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -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. */ diff --git a/src/fs/coss/StoreFScoss.cc b/src/fs/coss/StoreFScoss.cc index 2a0ed9771f..74c1b5485b 100644 --- a/src/fs/coss/StoreFScoss.cc +++ b/src/fs/coss/StoreFScoss.cc @@ -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; } diff --git a/src/htcp.cc b/src/htcp.cc index 2adcb279a8..ce1600d7d5 100644 --- a/src/htcp.cc +++ b/src/htcp.cc @@ -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)); } } diff --git a/src/mem.cc b/src/mem.cc index 0fb9a568f0..1b4ec8bf88 100644 --- a/src/mem.cc +++ b/src/mem.cc @@ -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"); diff --git a/src/pconn.cc b/src/pconn.cc index 12da503f42..39715a2a6e 100644 --- a/src/pconn.cc +++ b/src/pconn.cc @@ -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"); } diff --git a/src/repl/lru/store_repl_lru.cc b/src/repl/lru/store_repl_lru.cc index a93d188b4f..dcd1059b18 100644 --- a/src/repl/lru/store_repl_lru.cc +++ b/src/repl/lru/store_repl_lru.cc @@ -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); } diff --git a/src/store.cc b/src/store.cc index 647f7a6446..473b543556 100644 --- a/src/store.cc +++ b/src/store.cc @@ -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 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); } diff --git a/src/tools.cc b/src/tools.cc index cd6b3f36ec..b3faeb55ae 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -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(); diff --git a/test-suite/MemPoolTest.cc b/test-suite/MemPoolTest.cc index 74efcfef0d..72163e2955 100644 --- a/test-suite/MemPoolTest.cc +++ b/test-suite/MemPoolTest.cc @@ -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(Pool->alloc()); assert (something); diff --git a/test-suite/test_tools.cc b/test-suite/test_tools.cc index 1e26f60f7c..f4a62191b7 100644 --- a/test-suite/test_tools.cc +++ b/test-suite/test_tools.cc @@ -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_pool->alloc());