xine-lib 1.2.11
pool.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2000-2017 the xine project
3 *
4 * This file is part of xine, a free video player.
5 *
6 * xine is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * xine is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19 *
20 * Object Pool
21 */
22
23#include <stdlib.h>
24#include <inttypes.h>
25
26#include <xine/attributes.h>
27
28typedef struct xine_pool_s xine_pool_t;
29
30/* Creates a new pool
31 * object_size: sizeof(your struct)
32 * create_object: function called to create an object (can be NULL)
33 * prepare_object: function called to prepare an object to returned to the client (can be NULL)
34 * return_object: function called to prepare an object to returned to the pool (can be NULL)
35 * delete_object: function called to delete an object (can be NULL)
36 */
38 void (create_object)(void *object),
39 void (prepare_object)(void *object),
40 void (return_object)(void *object),
41 void (delete_object)(void *object)) XINE_MALLOC XINE_PROTECTED;
42
43/* Deletes a pool */
45
46/* Get an object from the pool */
48
49/* Returns an object to the pool */
50void xine_pool_put(xine_pool_t *pool, void *object) XINE_PROTECTED;
#define XINE_MALLOC
Definition: attributes.h:141
#define XINE_PROTECTED
Definition: attributes.h:75
void xine_pool_delete(xine_pool_t *pool)
Definition: pool.c:111
void * xine_pool_get(xine_pool_t *pool)
Definition: pool.c:134
void xine_pool_put(xine_pool_t *pool, void *object)
Definition: pool.c:181
xine_pool_t * xine_pool_new(size_t object_size, void(create_object)(void *object), void(prepare_object)(void *object), void(return_object)(void *object), void(delete_object)(void *object))
Definition: pool.c:40
void(* delete_object)(void *object)
Definition: pool.c:47
size_t object_size
Definition: pool.c:41
void(* prepare_object)(void *object)
Definition: pool.c:45
void(* return_object)(void *object)
Definition: pool.c:46
void(* create_object)(void *object)
Definition: pool.c:44