Struct mpool

Struct Documentation

struct mpool

Memory pool: a threadsafe malloc()/free() over a set of memory chunks.

Memory chunks must be fixed size.

Public Members

dptr_t *elements

The chunks of managed memory.

struct llist_node *nodes

Space for the llist nodes for both the free and allocated lists.

struct llist free

List of free chunks of memory.

struct llist alloc

List of free chunks of memory.

int *refs

Reference counting. Same length as max # elements.

size_t elt_size

Size of elements in the pool in bytes.

size_t max_elts

Max # of elements in the pool. Must be > 0.

struct csem slots_avail

Used to wait for a chunk to become free in mpool_req().

struct mutex mutex

Lock around most operations for concurrency safety.

uint32_t flags

Run time configuration flags. Valid flags are:

All other flags are ignored.