Struct

NumCosmoMathMemoryPool

Description [src]

struct NcmMemoryPool {
  /* No available fields */
}

Thread-safe pool of reusable objects.

Objects are allocated with a user-provided function, kept for reuse, and released with the corresponding free function.

Functions

ncm_memory_pool_new

Creates a pool that allocates objects with mp_alloc (called with userdata), reuses returned objects and frees them with mp_free. Objects must be returned with ncm_memory_pool_return().

ncm_memory_pool_return

Returns p, obtained from ncm_memory_pool_get(), to its pool.

Instance methods

ncm_memory_pool_add

Adds p, allocated as by the pool’s allocation function, to mp. The pool owns p under the same rules as the objects it allocates.

ncm_memory_pool_empty

Removes every slice from mp. The memory each slice points to is released with the pool’s free function only when free_slices is TRUE and such a function was given to ncm_memory_pool_new(). Blocks until all slices currently checked out have been returned.

ncm_memory_pool_free

Frees mp. The memory each slice points to is released with the pool’s free function only when free_slices is TRUE and such a function was given to ncm_memory_pool_new(). Blocks until all slices currently checked out have been returned.

ncm_memory_pool_get

Checks out the first unused slice, allocating a new one if all are in use.

ncm_memory_pool_set_min_size

Allocates slices until mp holds at least n.