|
|
@ -56,8 +56,12 @@ class buffer_pool{
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
// non-static methods
|
|
|
|
// non-static methods
|
|
|
|
buffer_pool(uint32_t nof_buffers = POOL_SIZE)
|
|
|
|
buffer_pool(int capacity_ = -1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
uint32_t nof_buffers = POOL_SIZE;
|
|
|
|
|
|
|
|
if (capacity > 0) {
|
|
|
|
|
|
|
|
nof_buffers = (uint32_t) capacity_;
|
|
|
|
|
|
|
|
}
|
|
|
|
pthread_mutex_init(&mutex, NULL);
|
|
|
|
pthread_mutex_init(&mutex, NULL);
|
|
|
|
for(uint32_t i=0;i<nof_buffers;i++) {
|
|
|
|
for(uint32_t i=0;i<nof_buffers;i++) {
|
|
|
|
buffer_t *b = new buffer_t;
|
|
|
|
buffer_t *b = new buffer_t;
|
|
|
@ -162,10 +166,10 @@ class byte_buffer_pool {
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
// Singleton static methods
|
|
|
|
// Singleton static methods
|
|
|
|
static byte_buffer_pool *instance;
|
|
|
|
static byte_buffer_pool *instance;
|
|
|
|
static byte_buffer_pool* get_instance(void);
|
|
|
|
static byte_buffer_pool* get_instance(int capacity = -1);
|
|
|
|
static void cleanup(void);
|
|
|
|
static void cleanup(void);
|
|
|
|
byte_buffer_pool() {
|
|
|
|
byte_buffer_pool(int capacity = -1) {
|
|
|
|
pool = new buffer_pool<byte_buffer_t>;
|
|
|
|
pool = new buffer_pool<byte_buffer_t>(capacity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
~byte_buffer_pool() {
|
|
|
|
~byte_buffer_pool() {
|
|
|
|
delete pool;
|
|
|
|
delete pool;
|
|
|
@ -178,7 +182,9 @@ public:
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b->reset();
|
|
|
|
b->reset();
|
|
|
|
pool->deallocate(b);
|
|
|
|
if (!pool->deallocate(b)) {
|
|
|
|
|
|
|
|
fprintf(stderr, "Error deallocating PDU: Addr=0x%lx not found in pool\n", (uint64_t) b);
|
|
|
|
|
|
|
|
}
|
|
|
|
b = NULL;
|
|
|
|
b = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void print_all_buffers() {
|
|
|
|
void print_all_buffers() {
|
|
|
|