mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-12-01 15:51:01 +01:00
CLEANUP: pools: make the local cache allocator fall back to the shared cache
Now when pool_get_from_local_cache() fails, it automatically falls back to pool_get_from_shared_cache(), which used to always be done in pool_get_from_cache(). Thus now the API is simpler as we always allocate and free from/to the local caches.
This commit is contained in:
parent
fa19d20ac4
commit
d56db11447
@ -74,6 +74,7 @@ extern THREAD_LOCAL size_t pool_cache_count; /* #cache objects */
|
|||||||
|
|
||||||
void pool_evict_from_local_cache(struct pool_head *pool);
|
void pool_evict_from_local_cache(struct pool_head *pool);
|
||||||
void pool_evict_from_local_caches();
|
void pool_evict_from_local_caches();
|
||||||
|
static inline void *pool_get_from_shared_cache(struct pool_head *pool);
|
||||||
|
|
||||||
/* returns true if the pool is considered to have too many free objects */
|
/* returns true if the pool is considered to have too many free objects */
|
||||||
static inline int pool_is_crowded(const struct pool_head *pool)
|
static inline int pool_is_crowded(const struct pool_head *pool)
|
||||||
@ -83,7 +84,8 @@ static inline int pool_is_crowded(const struct pool_head *pool)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Tries to retrieve an object from the local pool cache corresponding to pool
|
/* Tries to retrieve an object from the local pool cache corresponding to pool
|
||||||
* <pool>. Returns NULL if none is available.
|
* <pool>. If none is available, tries to allocate from the shared cache, and
|
||||||
|
* returns NULL if nothing is available.
|
||||||
*/
|
*/
|
||||||
static inline void *pool_get_from_local_cache(struct pool_head *pool)
|
static inline void *pool_get_from_local_cache(struct pool_head *pool)
|
||||||
{
|
{
|
||||||
@ -92,7 +94,7 @@ static inline void *pool_get_from_local_cache(struct pool_head *pool)
|
|||||||
|
|
||||||
ph = &pool->cache[tid];
|
ph = &pool->cache[tid];
|
||||||
if (LIST_ISEMPTY(&ph->list))
|
if (LIST_ISEMPTY(&ph->list))
|
||||||
return NULL; // empty
|
return pool_get_from_shared_cache(pool);
|
||||||
|
|
||||||
item = LIST_NEXT(&ph->list, typeof(item), by_pool);
|
item = LIST_NEXT(&ph->list, typeof(item), by_pool);
|
||||||
ph->count--;
|
ph->count--;
|
||||||
@ -278,8 +280,6 @@ static inline void *pool_get_from_cache(struct pool_head *pool)
|
|||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
ptr = pool_get_from_local_cache(pool);
|
ptr = pool_get_from_local_cache(pool);
|
||||||
if (!ptr)
|
|
||||||
ptr = pool_get_from_shared_cache(pool);
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user