3 * ***** BEGIN GPL LICENSE BLOCK *****
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 * Contributor(s): Peter Schlaile <peter@schlaile.de> 2005
21 * ***** END GPL LICENSE BLOCK *****
24 #ifndef __MEM_cache_limiter_c_api_h_included__
25 #define __MEM_cache_limiter_c_api_h_included__ 1
31 struct MEM_CacheLimiter_s;
32 struct MEM_CacheLimiterHandle_s;
34 typedef struct MEM_CacheLimiter_s MEM_CacheLimiterC;
35 typedef struct MEM_CacheLimiterHandle_s MEM_CacheLimiterHandleC;
37 /* function used to remove data from memory */
38 typedef void(*MEM_CacheLimiter_Destruct_Func)(void*);
40 #ifndef __MEM_cache_limiter_h_included__
41 extern void MEM_CacheLimiter_set_maximum(int m);
42 extern int MEM_CacheLimiter_get_maximum();
45 * Create new MEM_CacheLimiter object
46 * managed objects are destructed with the data_destructor
48 * @param data_destructor
49 * @return A new MEM_CacheLimter object
52 extern MEM_CacheLimiterC * new_MEM_CacheLimiter(
53 MEM_CacheLimiter_Destruct_Func data_destructor);
56 * Delete MEM_CacheLimiter
58 * Frees the memory of the CacheLimiter but does not touch managed objects!
60 * @param This "This" pointer
63 extern void delete_MEM_CacheLimiter(MEM_CacheLimiterC * This);
68 * @param This "This" pointer, data data object to manage
69 * @return CacheLimiterHandle to ref, unref, touch the managed object
72 extern MEM_CacheLimiterHandleC * MEM_CacheLimiter_insert(
73 MEM_CacheLimiterC * This, void * data);
76 * Free objects until memory constraints are satisfied
78 * @param This "This" pointer
81 extern void MEM_CacheLimiter_enforce_limits(MEM_CacheLimiterC * This);
84 * Unmanage object previously inserted object.
85 * Does _not_ delete managed object!
87 * @param This "This" pointer, handle of object
90 extern void MEM_CacheLimiter_unmanage(MEM_CacheLimiterHandleC * handle);
94 * Raise priority of object (put it at the tail of the deletion chain)
96 * @param handle of object
99 extern void MEM_CacheLimiter_touch(MEM_CacheLimiterHandleC * handle);
102 * Increment reference counter. Objects with reference counter != 0 are _not_
105 * @param handle of object
108 extern void MEM_CacheLimiter_ref(MEM_CacheLimiterHandleC * handle);
111 * Decrement reference counter. Objects with reference counter != 0 are _not_
114 * @param handle of object
117 extern void MEM_CacheLimiter_unref(MEM_CacheLimiterHandleC * handle);
120 * Get reference counter.
122 * @param This "This" pointer, handle of object
125 extern int MEM_CacheLimiter_get_refcount(MEM_CacheLimiterHandleC * handle);
128 * Get pointer to managed object
130 * @param handle of object
133 extern void * MEM_CacheLimiter_get(MEM_CacheLimiterHandleC * handle);