FFmpeg
|
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... | |
RefCount * | available_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 |
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.
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().
AVRefStructOpaque AVRefStructPool::opaque |
Definition at line 185 of file refstruct.c.
Referenced by av_refstruct_pool_alloc_ext(), av_refstruct_pool_alloc_ext_c(), pool_free(), pool_free_entry(), pool_reset_entry(), and refstruct_pool_get_ext().
int(* AVRefStructPool::init_cb) (AVRefStructOpaque opaque, void *obj) |
Definition at line 186 of file refstruct.c.
Referenced by av_refstruct_pool_alloc_ext(), av_refstruct_pool_alloc_ext_c(), and refstruct_pool_get_ext().
void(* AVRefStructPool::reset_cb) (AVRefStructOpaque opaque, void *obj) |
Definition at line 187 of file refstruct.c.
Referenced by av_refstruct_pool_alloc_ext(), av_refstruct_pool_alloc_ext_c(), pool_reset_entry(), and refstruct_pool_get_ext().
void(* AVRefStructPool::free_entry_cb) (AVRefStructOpaque opaque, void *obj) |
Definition at line 188 of file refstruct.c.
Referenced by av_refstruct_pool_alloc_ext(), av_refstruct_pool_alloc_ext_c(), pool_free_entry(), and refstruct_pool_get_ext().
void(* AVRefStructPool::free_cb) (AVRefStructOpaque opaque) |
Definition at line 189 of file refstruct.c.
Referenced by av_refstruct_pool_alloc_ext(), av_refstruct_pool_alloc_ext_c(), and pool_free().
int AVRefStructPool::uninited |
Definition at line 191 of file refstruct.c.
Referenced by pool_return_entry(), refstruct_pool_get_ext(), and refstruct_pool_uninit().
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().
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().
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().
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().
AVMutex AVRefStructPool::mutex |
Definition at line 205 of file refstruct.c.
Referenced by av_refstruct_pool_alloc_ext_c(), pool_free(), pool_return_entry(), refstruct_pool_get_ext(), and refstruct_pool_uninit().