only meant to be used via the CLASS macros.
virtual void free(void *) = 0;
virtual char const *objectType() const;
virtual size_t objectSize() const = 0;
+ int inUseCount();
private:
const char *label;
};
/*
- * $Id: MemPool.cc,v 1.4 2006/09/03 04:09:35 hno Exp $
+ * $Id: MemPool.cc,v 1.5 2006/09/03 04:11:59 hno Exp $
*
* DEBUG: section 63 Low Level Memory Pool Management
* AUTHOR: Alex Rousskov, Andres Kroonmaa, Robert Collins
return label;
}
+int
+MemAllocator::inUseCount()
+{
+ MemPoolStats stats;
+ getStats(&stats);
+ return stats.items_inuse;
+}
+
void
MemImplementingAllocator::flushMeters()
{
int
memPoolInUseCount(MemAllocator * pool)
{
- MemPoolStats stats;
- assert(pool != NULL);
- pool->getStats(&stats);
- return stats.items_inuse;
+ return pool->inUseCount();
}
int
/*
- * $Id: DiskThreadsIOStrategy.cc,v 1.7 2006/06/17 16:36:15 serassio Exp $
+ * $Id: DiskThreadsIOStrategy.cc,v 1.8 2006/09/03 04:12:00 hno Exp $
*
* DEBUG: section 79 Squid-side Disk I/O functions.
* AUTHOR: Robert Collins
#include "Store.h"
#include "fde.h"
-//static MemAllocatorProxy *squidaio_ctrl_pool;
-
void
DiskThreadsIOStrategy::init(void)
{
if (initialised)
return;
- squidaio_ctrl_pool = new MemAllocatorProxy("aio_ctrl", sizeof(squidaio_ctrl_t));
+ squidaio_ctrl_pool = MemPools::GetInstance().create("aio_ctrl", sizeof(squidaio_ctrl_t));
initialised = true;
/*
- * $Id: DiskThreadsIOStrategy.h,v 1.3 2006/05/29 00:15:03 robertc Exp $
+ * $Id: DiskThreadsIOStrategy.h,v 1.4 2006/09/03 04:12:00 hno Exp $
*
* DEBUG: section 79 Squid-side Disk I/O functions.
* AUTHOR: Robert Collins
/* Todo: add access limitations */
bool initialised;
static DiskThreadsIOStrategy Instance;
- MemAllocatorProxy *squidaio_ctrl_pool;
+ MemAllocator *squidaio_ctrl_pool;
private:
static void aioStats(StoreEntry * sentry);
/*
- * $Id: aiops.cc,v 1.10 2006/08/07 02:28:22 robertc Exp $
+ * $Id: aiops.cc,v 1.11 2006/09/03 04:12:01 hno Exp $
*
* DEBUG: section 43 AIOPS
* AUTHOR: Stewart Forster <slf@connect.com.au>
#define AIO_TINY_BUFS AIO_LARGE_BUFS >> 3
#define AIO_MICRO_BUFS 128
-static MemAllocatorProxy *squidaio_large_bufs = NULL; /* 16K */
-static MemAllocatorProxy *squidaio_medium_bufs = NULL; /* 8K */
-static MemAllocatorProxy *squidaio_small_bufs = NULL; /* 4K */
-static MemAllocatorProxy *squidaio_tiny_bufs = NULL; /* 2K */
-static MemAllocatorProxy *squidaio_micro_bufs = NULL; /* 128K */
+static MemAllocator *squidaio_large_bufs = NULL; /* 16K */
+static MemAllocator *squidaio_medium_bufs = NULL; /* 8K */
+static MemAllocator *squidaio_small_bufs = NULL; /* 4K */
+static MemAllocator *squidaio_tiny_bufs = NULL; /* 2K */
+static MemAllocator *squidaio_micro_bufs = NULL; /* 128K */
static int request_queue_len = 0;
-static MemAllocatorProxy *squidaio_request_pool = NULL;
-static MemAllocatorProxy *squidaio_thread_pool = NULL;
+static MemAllocator *squidaio_request_pool = NULL;
+static MemAllocator *squidaio_thread_pool = NULL;
static squidaio_request_queue_t request_queue;
static struct
#endif
static pthread_t main_thread;
-static MemAllocatorProxy *
+static MemAllocator *
squidaio_get_pool(int size)
{
- MemAllocatorProxy *p;
-
if (size <= AIO_LARGE_BUFS) {
if (size <= AIO_MICRO_BUFS)
- p = squidaio_micro_bufs;
+ return squidaio_micro_bufs;
else if (size <= AIO_TINY_BUFS)
- p = squidaio_tiny_bufs;
+ return squidaio_tiny_bufs;
else if (size <= AIO_SMALL_BUFS)
- p = squidaio_small_bufs;
+ return squidaio_small_bufs;
else if (size <= AIO_MEDIUM_BUFS)
- p = squidaio_medium_bufs;
+ return squidaio_medium_bufs;
else
- p = squidaio_large_bufs;
- } else
- p = NULL;
+ return squidaio_large_bufs;
+ }
- return p;
+ return NULL;
}
void *
squidaio_xmalloc(int size)
{
void *p;
- MemAllocatorProxy *pool;
+ MemAllocator *pool;
if ((pool = squidaio_get_pool(size)) != NULL) {
p = pool->alloc();
void
squidaio_xfree(void *p, int size)
{
- MemAllocatorProxy *pool;
+ MemAllocator *pool;
if ((pool = squidaio_get_pool(size)) != NULL) {
pool->free(p);
static void
squidaio_xstrfree(char *str)
{
- MemAllocatorProxy *pool;
+ MemAllocator *pool;
int len = strlen(str) + 1;
if ((pool = squidaio_get_pool(len)) != NULL) {
done_queue.blocked = 0;
/* Create threads and get them to sit in their wait loop */
- squidaio_thread_pool = new MemAllocatorProxy("aio_thread", sizeof(squidaio_thread_t));
+ squidaio_thread_pool = MemPools::GetInstance().create("aio_thread", sizeof(squidaio_thread_t));
assert(NUMTHREADS);
}
/* Create request pool */
- squidaio_request_pool = new MemAllocatorProxy("aio_request", sizeof(squidaio_request_t));
+ squidaio_request_pool = MemPools::GetInstance().create("aio_request", sizeof(squidaio_request_t));
- squidaio_large_bufs = new MemAllocatorProxy("squidaio_large_bufs", AIO_LARGE_BUFS);
+ squidaio_large_bufs = MemPools::GetInstance().create("squidaio_large_bufs", AIO_LARGE_BUFS);
- squidaio_medium_bufs = new MemAllocatorProxy("squidaio_medium_bufs", AIO_MEDIUM_BUFS);
+ squidaio_medium_bufs = MemPools::GetInstance().create("squidaio_medium_bufs", AIO_MEDIUM_BUFS);
- squidaio_small_bufs = new MemAllocatorProxy("squidaio_small_bufs", AIO_SMALL_BUFS);
+ squidaio_small_bufs = MemPools::GetInstance().create("squidaio_small_bufs", AIO_SMALL_BUFS);
- squidaio_tiny_bufs = new MemAllocatorProxy("squidaio_tiny_bufs", AIO_TINY_BUFS);
+ squidaio_tiny_bufs = MemPools::GetInstance().create("squidaio_tiny_bufs", AIO_TINY_BUFS);
- squidaio_micro_bufs = new MemAllocatorProxy("squidaio_micro_bufs", AIO_MICRO_BUFS);
+ squidaio_micro_bufs = MemPools::GetInstance().create("squidaio_micro_bufs", AIO_MICRO_BUFS);
squidaio_initialised = 1;
}
/*
- * $Id: auth_digest.cc,v 1.48 2006/08/07 02:28:24 robertc Exp $
+ * $Id: auth_digest.cc,v 1.49 2006/09/03 04:12:01 hno Exp $
*
* DEBUG: section 29 Authenticator
* AUTHOR: Robert Collins
static AuthDigestConfig digestConfig;
static int authdigest_initialised = 0;
-static MemAllocatorProxy *digest_nonce_pool = NULL;
+static MemAllocator *digest_nonce_pool = NULL;
CBDATA_TYPE(DigestAuthenticateStateData);
authenticateDigestNonceSetup(void)
{
if (!digest_nonce_pool)
- digest_nonce_pool = new MemAllocatorProxy("Digest Scheme nonce's", sizeof(digest_nonce_h));
+ digest_nonce_pool = MemPools::GetInstance().create("Digest Scheme nonce's", sizeof(digest_nonce_h));
if (!digest_nonce_cache) {
digest_nonce_cache = hash_create((HASHCMP *) strcmp, 7921, hash_string);
/*
- * $Id: auth_negotiate.cc,v 1.10 2006/07/07 19:10:30 serassio Exp $
+ * $Id: auth_negotiate.cc,v 1.11 2006/09/03 04:12:01 hno Exp $
*
* DEBUG: section 29 Negotiate Authenticator
* AUTHOR: Robert Collins, Henrik Nordstrom, Francesco Chemolli
static int authnegotiate_initialised = 0;
-//static MemAllocatorProxy *negotiate_user_hash_pool = NULL;
-
static auth_negotiate_config negotiateConfig;
static hash_table *proxy_auth_cache = NULL;
AuthNegotiateConfig::init(AuthConfig * scheme)
{
if (authenticate) {
-#if PLACEHOLDER
-
- if (!negotiate_user_hash_pool)
-
- negotiate_user_hash_pool = new MemAllocatorProxy("Negotiate Header Hash Data", sizeof(struct ProxyAuthCachePointer));
-
-#endif
-
authnegotiate_initialised = 1;
if (negotiateauthenticators == NULL)
/*
- * $Id: auth_ntlm.cc,v 1.59 2006/07/07 19:10:30 serassio Exp $
+ * $Id: auth_ntlm.cc,v 1.60 2006/09/03 04:12:02 hno Exp $
*
* DEBUG: section 29 NTLM Authenticator
* AUTHOR: Robert Collins, Henrik Nordstrom, Francesco Chemolli
static int authntlm_initialised = 0;
-//static MemAllocatorProxy *ntlm_user_hash_pool = NULL;
-
static auth_ntlm_config ntlmConfig;
static hash_table *proxy_auth_cache = NULL;
AuthNTLMConfig::init(AuthConfig * scheme)
{
if (authenticate) {
-#if PLACEHOLDER
-
- if (!ntlm_user_hash_pool)
-
- ntlm_user_hash_pool = new MemAllocatorProxy("NTLM Header Hash Data", sizeof(struct ProxyAuthCachePointer));
-
-#endif
authntlm_initialised = 1;
/*
- * $Id: StoreFScoss.cc,v 1.5 2006/05/29 00:15:09 robertc Exp $
+ * $Id: StoreFScoss.cc,v 1.6 2006/09/03 04:12:02 hno Exp $
*
* DEBUG: section 47 Store Directory Routines
* AUTHOR: Robert Collins
{
assert(!initialised);
- coss_index_pool = new MemAllocatorProxy("COSS index data", sizeof(CossIndexNode));
+ coss_index_pool = MemPools::GetInstance().create("COSS index data", sizeof(CossIndexNode));
initialised = true;
}
/* Whether the coss system has been setup or not */
extern int coss_initialised;
-extern MemAllocatorProxy *coss_membuf_pool;
-extern MemAllocatorProxy *coss_index_pool;
+extern MemAllocator *coss_membuf_pool;
+extern MemAllocator *coss_index_pool;
#include "DiskIO/ReadRequest.h"
/*
- * $Id: store_dir_coss.cc,v 1.66 2006/08/19 12:31:21 robertc Exp $
+ * $Id: store_dir_coss.cc,v 1.67 2006/09/03 04:12:03 hno Exp $
* vim: set et :
*
* DEBUG: section 47 Store COSS Directory Routines
int n_coss_dirs = 0;
/* static int last_coss_pick_index = -1; */
-MemAllocatorProxy *coss_index_pool = NULL;
+MemAllocator *coss_index_pool = NULL;
typedef struct _RebuildState RebuildState;
/*
- * $Id: helper.h,v 1.5 2006/09/02 15:24:08 serassio Exp $
+ * $Id: helper.h,v 1.6 2006/09/03 04:11:59 hno Exp $
*
* DEBUG: section 84 Helper process maintenance
* AUTHOR: Harvest Derived?
int n_running;
int n_active;
int ipc_type;
- MemAllocatorProxy *datapool;
+ MemAllocator *datapool;
HLPSAVAIL *IsAvailable;
HLPSONEQ *OnEmptyQueue;
time_t last_queue_warn;
/*
- * $Id: store_repl_lru.cc,v 1.18 2006/08/21 00:50:47 robertc Exp $
+ * $Id: store_repl_lru.cc,v 1.19 2006/09/03 04:12:04 hno Exp $
*
* DEBUG: section ? LRU Removal policy
* AUTHOR: Henrik Nordstrom
dlink_node node;
};
-static MemPool *lru_node_pool = NULL;
+static MemImplementingAllocator *lru_node_pool = NULL;
static int nr_lru_policies = 0;
static void
if (!lru_node_pool) {
/* Must be chunked */
- lru_node_pool = new MemPool("LRU policy node", sizeof(LruNode));
+ lru_node_pool = MemPools::GetInstance().create("LRU policy node", sizeof(LruNode));
lru_node_pool->setChunkSize(512 * 1024);
}
/*
- * $Id: MemPoolTest.cc,v 1.3 2004/08/30 05:12:33 robertc Exp $
+ * $Id: MemPoolTest.cc,v 1.4 2006/09/03 04:12:04 hno Exp $
*
* AUTHOR: Robert Collins
*
};
static MemPool *Pool;
};
-MemPool *MemPoolTest::Pool = NULL;
+MemAllocator *MemPoolTest::Pool = NULL;
void
MemPoolTest::run()
{
assert (Pool == NULL);
- Pool = new MemPool ("Test Pool", sizeof(SomethingToAlloc));
+ Pool = MemPools::GetInstance().create("Test Pool", sizeof(SomethingToAlloc));
assert (Pool);
SomethingToAlloc *something = static_cast<SomethingToAlloc *>(Pool->alloc());
assert (something);