mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-26 19:01:56 -04:00
Rework node obj pool to use objpool
This commit is contained in:
parent
160d3c832d
commit
3f70e66ee3
4 changed files with 44 additions and 68 deletions
|
|
@ -1,60 +1,29 @@
|
|||
#include "node.hpp"
|
||||
|
||||
#include "lfmp.h"
|
||||
#include "objpool.hpp"
|
||||
|
||||
static lfmp_t g_NODE_FMP;
|
||||
|
||||
static
|
||||
__attribute__((constructor))
|
||||
void
|
||||
node_constructor()
|
||||
{
|
||||
lfmp_init(&g_NODE_FMP,sizeof(node_t),256);
|
||||
}
|
||||
|
||||
static
|
||||
__attribute__((destructor))
|
||||
void
|
||||
node_destructor()
|
||||
{
|
||||
lfmp_destroy(&g_NODE_FMP);
|
||||
}
|
||||
static ObjPool<node_t> g_NODE_POOL;
|
||||
|
||||
node_t*
|
||||
node_alloc()
|
||||
{
|
||||
return (node_t*)lfmp_calloc(&g_NODE_FMP);
|
||||
return g_NODE_POOL.alloc();
|
||||
}
|
||||
|
||||
void
|
||||
node_free(node_t *node_)
|
||||
{
|
||||
lfmp_free(&g_NODE_FMP,node_);
|
||||
}
|
||||
|
||||
int
|
||||
node_gc1()
|
||||
{
|
||||
return lfmp_gc(&g_NODE_FMP);
|
||||
g_NODE_POOL.free(node_);
|
||||
}
|
||||
|
||||
void
|
||||
node_gc()
|
||||
{
|
||||
int rv;
|
||||
int fails;
|
||||
|
||||
fails = 0;
|
||||
do
|
||||
{
|
||||
rv = node_gc1();
|
||||
if(rv == 0)
|
||||
fails++;
|
||||
} while(rv || (fails < 3));
|
||||
g_NODE_POOL.gc();
|
||||
}
|
||||
|
||||
lfmp_t*
|
||||
node_lfmp()
|
||||
void
|
||||
node_clear()
|
||||
{
|
||||
return &g_NODE_FMP;
|
||||
g_NODE_POOL.clear();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue