virtual void free(void *) = 0;
virtual char const *objectType() const;
virtual size_t objectSize() const = 0;
+ virtual int getInUseCount() = 0;
int inUseCount();
virtual void setChunkSize(size_t chunksize) {}
private:
/* Hint to the allocator - may be ignored */
virtual void setChunkSize(size_t chunksize) {}
virtual size_t objectSize() const;
+ virtual int getInUseCount() = 0;
protected:
virtual void *allocate() = 0;
virtual void deallocate(void *) = 0;
void createChunk();
void *get();
void push(void *obj);
+ virtual int getInUseCount();
protected:
virtual void *allocate();
virtual void deallocate(void *);
virtual bool idleTrigger(int shift) const;
virtual void clean(time_t maxage);
virtual int getStats(MemPoolStats * stats);
+ virtual int getInUseCount();
protected:
virtual void *allocate();
virtual void deallocate(void *);
+ private:
+ int inuse;
};
class MemChunk
/*
- * $Id: MemPool.cc,v 1.5 2006/09/03 04:11:59 hno Exp $
+ * $Id: MemPool.cc,v 1.6 2006/09/20 00:59:26 adrian Exp $
*
* DEBUG: section 63 Low Level Memory Pool Management
* AUTHOR: Alex Rousskov, Andres Kroonmaa, Robert Collins
int
MemAllocator::inUseCount()
{
- MemPoolStats stats;
- getStats(&stats);
- return stats.items_inuse;
+ return getInUseCount();
}
void
void *
MemMalloc::allocate()
{
+ inuse++;
return xcalloc(1, obj_size);
}
void
MemMalloc::deallocate(void *obj)
{
+ inuse--;
xfree(obj);
}
++free_calls;
}
+int
+MemPool::getInUseCount()
+{
+ return inuse;
+}
+
void *
MemPool::allocate()
{
return getMeter().inuse.level;
}
+int
+MemMalloc::getInUseCount()
+{
+ return inuse;
+}
+
/*
* Totals statistics is returned
*/
{
}
-MemMalloc::MemMalloc(char const *label, size_t aSize) : MemImplementingAllocator(label, aSize) {}
+MemMalloc::MemMalloc(char const *label, size_t aSize) : MemImplementingAllocator(label, aSize) { inuse = 0; }
bool
MemMalloc::idleTrigger(int shift) const
/*
- * $Id: MemObject.cc,v 1.23 2006/08/21 00:50:41 robertc Exp $
+ * $Id: MemObject.cc,v 1.24 2006/09/20 00:59:26 adrian Exp $
*
* DEBUG: section 19 Store Memory Primitives
* AUTHOR: Robert Collins
size_t
MemObject::inUseCount()
{
- MemPoolStats stats;
-
- Pool().getStats (&stats);
-
- return stats.items_inuse;
+ return Pool().inUseCount();
}
MemObject::MemObject(char const *aUrl, char const *aLog_url)
/*
- * $Id: mem_node.cc,v 1.8 2005/11/02 22:19:22 serassio Exp $
+ * $Id: mem_node.cc,v 1.9 2006/09/20 00:59:27 adrian Exp $
*
* DEBUG: section 19 Store Memory Primitives
* AUTHOR: Robert Collins
size_t
mem_node::InUseCount()
{
- MemPoolStats stats;
-
- Pool().getStats (&stats);
-
- return stats.items_inuse;
+ return Pool().inUseCount();
}
size_t
/*
- * $Id: store.cc,v 1.600 2006/09/03 21:05:20 hno Exp $
+ * $Id: store.cc,v 1.601 2006/09/20 00:59:27 adrian Exp $
*
* DEBUG: section 20 Storage Manager
* AUTHOR: Harvest Derived
{
if (!pool)
return 0;
-
- MemPoolStats stats;
-
- pool->getStats (&stats);
-
- return stats.items_inuse;
+ return pool->getInUseCount();
}
const char *