FFmpeg
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Data Fields
AVRefStructPool Struct Reference

AVRefStructPool is an API for a thread-safe pool of objects managed via the RefStruct API. More...

Data Fields

size_t size
 
AVRefStructOpaque opaque
 
int(* init_cb )(AVRefStructOpaque opaque, void *obj)
 
void(* reset_cb )(AVRefStructOpaque opaque, void *obj)
 
void(* free_entry_cb )(AVRefStructOpaque opaque, void *obj)
 
void(* free_cb )(AVRefStructOpaque opaque)
 
int uninited
 
unsigned entry_flags
 
unsigned pool_flags
 
atomic_uintptr_t refcount
 The number of outstanding entries not in available_entries. More...
 
RefCountavailable_entries
 This is a linked list of available entries; the RefCount's opaque pointer is used as next pointer for available entries. More...
 
AVMutex mutex
 

Detailed Description

AVRefStructPool is an API for a thread-safe pool of objects managed via the RefStruct API.

Frequently allocating and freeing large or complicated objects may be slow and wasteful. This API is meant to solve this in cases when the caller needs a set of interchangable objects.

At the beginning, the user must call allocate the pool via av_refstruct_pool_alloc() or its analogue av_refstruct_pool_alloc_ext(). Then whenever an object is needed, call av_refstruct_pool_get() to get a new or reused object from the pool. This new object works in all aspects the same way as the ones created by av_refstruct_alloc_ext(). However, when the last reference to this object is unreferenced, it is (optionally) reset and returned to the pool instead of being freed and will be reused for subsequent av_refstruct_pool_get() calls.

When the caller is done with the pool and no longer needs to create any new objects, av_refstruct_pool_uninit() must be called to mark the pool as freeable. Then entries returned to the pool will then be freed. Once all the entries are freed, the pool will automatically be freed.

Allocating and releasing objects with this API is thread-safe as long as the user-supplied callbacks (if provided) are thread-safe. The buffer pool. This structure is opaque and not meant to be accessed directly. It is allocated with the allocators below and freed with av_refstruct_pool_uninit().

Definition at line 183 of file refstruct.c.

Field Documentation

◆ size

size_t AVRefStructPool::size

Definition at line 184 of file refstruct.c.

Referenced by av_refstruct_pool_alloc_ext_c(), and refstruct_pool_get_ext().

◆ opaque

AVRefStructOpaque AVRefStructPool::opaque

◆ init_cb

int(* AVRefStructPool::init_cb) (AVRefStructOpaque opaque, void *obj)

◆ reset_cb

void(* AVRefStructPool::reset_cb) (AVRefStructOpaque opaque, void *obj)

◆ free_entry_cb

void(* AVRefStructPool::free_entry_cb) (AVRefStructOpaque opaque, void *obj)

◆ free_cb

void(* AVRefStructPool::free_cb) (AVRefStructOpaque opaque)

◆ uninited

int AVRefStructPool::uninited

Definition at line 191 of file refstruct.c.

Referenced by pool_return_entry(), refstruct_pool_get_ext(), and refstruct_pool_uninit().

◆ entry_flags

unsigned AVRefStructPool::entry_flags

Definition at line 192 of file refstruct.c.

Referenced by av_refstruct_pool_alloc_ext_c(), and refstruct_pool_get_ext().

◆ pool_flags

unsigned AVRefStructPool::pool_flags

Definition at line 193 of file refstruct.c.

Referenced by av_refstruct_pool_alloc_ext_c(), and refstruct_pool_get_ext().

◆ refcount

atomic_uintptr_t AVRefStructPool::refcount

The number of outstanding entries not in available_entries.

Definition at line 196 of file refstruct.c.

Referenced by av_refstruct_pool_alloc_ext_c(), pool_return_entry(), pool_unref(), and refstruct_pool_get_ext().

◆ available_entries

RefCount* AVRefStructPool::available_entries

This is a linked list of available entries; the RefCount's opaque pointer is used as next pointer for available entries.

While the entries are in use, the opaque is a pointer to the corresponding AVRefStructPool.

Definition at line 204 of file refstruct.c.

Referenced by pool_return_entry(), refstruct_pool_get_ext(), and refstruct_pool_uninit().

◆ mutex

AVMutex AVRefStructPool::mutex

The documentation for this struct was generated from the following file: