![]() |
EM-ODP 4.4.0
Event Machine on ODP
|


Go to the source code of this file.
Data Structures | |
| struct | objpool_elem_t |
| union | objsubpool_t |
| struct | objpool_t |
Macros | |
| #define | OBJSUBPOOLS_MAX 8 |
Functions | |
| COMPILE_TIME_ASSERT (2 *sizeof(objsubpool_t)==ENV_CACHE_LINE_SIZE, OBJSUBPOOL_T_SIZE_ERROR) | |
| int | objpool_init (objpool_t *const objpool, uint32_t nbr_subpools) |
| uint32_t | objpool_subpools (const objpool_t *const objpool) |
| void | objpool_add (objpool_t *const objpool, uint32_t subpool_idx, objpool_elem_t *const elem) |
| objpool_elem_t * | objpool_rem (objpool_t *const objpool, uint32_t subpool_idx) |
| int | objpool_rem_elem (objpool_t *const objpool, objpool_elem_t *const elem) |
Simple object pool for managing collections of objects.
Objects stored in the pool must embed an objpool_elem_t member that is used internally to link the object into the pool. The pool is divided into independently locked subpools to reduce contention in multithreaded use.
Definition in file objpool.h.
| #define OBJSUBPOOLS_MAX 8 |
Maximum number of subpools in an object pool.
This compile-time limit is set to 8 as a balance between reducing lock contention (more subpools) and keeping the objpool_t structure small enough to preserve cache locality. Increasing this value is possible if a particular workload benefits from more independently locked subpools, but doing so will grow the size of objpool_t proportionally.
| void objpool_add | ( | objpool_t *const | objpool, |
| uint32_t | subpool_idx, | ||
| objpool_elem_t *const | elem | ||
| ) |
| int objpool_init | ( | objpool_t *const | objpool, |
| uint32_t | nbr_subpools | ||
| ) |
| objpool_elem_t * objpool_rem | ( | objpool_t *const | objpool, |
| uint32_t | subpool_idx | ||
| ) |
Remove and return an object from the object pool.
Tries the given subpool first, then searches the remaining subpools round-robin until a free object is found.
| objpool | Object pool. |
| subpool_idx | Preferred subpool index to remove from first. |
| int objpool_rem_elem | ( | objpool_t *const | objpool, |
| objpool_elem_t *const | elem | ||
| ) |