Richard Salz wrote in
<CAFH29tpbNrUKVP2hp25wdu9BYCxQr+RrmcWJ8F+SbtwsGE4VKw(a)mail.gmail.com>:
|Apache has the "pool" concept, per-request storage; there are a few
And BSD Mail had the "stringdope" of Kurt Shoens from the very
start in 1978. It serves allocations of various size until reset
time. (Different to the Apache thing it does not support
destructor calls -- if i recall the Apache stuff, i have looked
into that two decades ago.)
I personally had objects caches and fluctuating object caches
backed by generic C types
pub GOCache(uir _objsz, uir _growby=8-1);
...
pub uir count(void) const { return(m_count); }
pub void *alloc(void);
pub GOCache &free(void *_ptr);
pub GOCache &clear(void);
pub GOCache &swap(GOCache &_t);
and used via all-inline template wrappers
template<class T> class OCache : private GOCache{
...
OCache(uir _growby=8-1) : Super(szof(T), _growby) {}
...
pub T *newObject(void) { return(SF_newHeap(T, Super::alloc())); }
pub OCache &delObject(T *_tptr){
_AssertRetThis(_tptr != NIL);
_tptr->~T();
return(s(Me&,Super::free(_tptr)));
}
...
The difference was that the normal could not free individual
chunks, the other could
pri union Atom{
Chunk *owner; // used
Atom *next; // free
}SF_CC_PACKED;
pri struct Chunk{
Chunk *right;
Atom *free; // freelist
ui1 *top; // cast point or NIL if full
uir count; // user pointers this Chunk
}SF_CC_PACKED;
vs
pri struct Atom{
Atom *next;
}SF_CC_PACKED;
pri struct Chunk{
Chunk *right;
ui1 *top; // cast point or NIL if full
}SF_CC_PACKED;
(here the free Atom free list was part of the cache object).
That even worked out fine to serve nodes on hashmap and list
objects, in practice.
|versions:
|
https://commons.apache.org/proper/commons-pool/ (java)
|
http://www.apachetutor.org/dev/pools (C server)
--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)