Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
object_pool.h File Reference

Thread-safe object pool implementation. More...

#include "utils/types.h"
#include "zix/sem.h"
Include dependency graph for object_pool.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ObjectPool
 

Typedefs

typedef void *(* ObjectCreatorFunc) (void)
 Function to call to create the objects in the pool.
 

Functions

ObjectPoolobject_pool_new (ObjectCreatorFunc create_func, ObjectFreeFunc free_func, int max_objects)
 Creates a new object pool.
 
void * object_pool_get (ObjectPool *self)
 Returns an available object.
 
int object_pool_get_num_available (ObjectPool *self)
 Returns the number of available objects.
 
void object_pool_return (ObjectPool *self, void *object)
 Puts an object back in the pool.
 
void object_pool_free (ObjectPool *self)
 Frees the pool and all its objects.
 

Detailed Description

Thread-safe object pool implementation.

Definition in file object_pool.h.

Typedef Documentation

◆ ObjectCreatorFunc

typedef void *(* ObjectCreatorFunc) (void)

Function to call to create the objects in the pool.

Definition at line 21 of file object_pool.h.

Function Documentation

◆ object_pool_get_num_available()

int object_pool_get_num_available ( ObjectPool self)

Returns the number of available objects.

Note
This is not accurate (since the number may change after it's called) and is used only for debugging purposes.