Blame docs/reference/glib/html/glib-Caches.html

Packit ae235b
Packit ae235b
<html>
Packit ae235b
<head>
Packit ae235b
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Packit ae235b
<title>Caches: GLib Reference Manual</title>
Packit ae235b
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
Packit ae235b
<link rel="home" href="index.html" title="GLib Reference Manual">
Packit ae235b
<link rel="up" href="deprecated.html" title="Deprecated APIs">
Packit ae235b
<link rel="prev" href="glib-Deprecated-Thread-APIs.html" title="Deprecated thread API">
Packit ae235b
<link rel="next" href="glib-Relations-and-Tuples.html" title="Relations and Tuples">
Packit ae235b
<meta name="generator" content="GTK-Doc V1.27 (XML mode)">
Packit ae235b
<link rel="stylesheet" href="style.css" type="text/css">
Packit ae235b
</head>
Packit ae235b
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
Packit ae235b
Packit ae235b
Packit ae235b
Top  | 
Packit ae235b
                  Description
Packit ae235b
Packit ae235b
Home
Packit ae235b
Up
Packit ae235b
Prev
Packit ae235b
Next
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Caches

Packit ae235b

Caches — caches allow sharing of complex data structures

Packit ae235b
                    to save resources

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Functions

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GCache *
Packit ae235b
Packit ae235b
Packit ae235b
g_cache_new ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gpointer
Packit ae235b
Packit ae235b
Packit ae235b
g_cache_insert ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_cache_remove ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_cache_destroy ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_cache_key_foreach ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_cache_value_foreach ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
(*GCacheDestroyFunc) ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gpointer
Packit ae235b
Packit ae235b
Packit ae235b
(*GCacheDupFunc) ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gpointer
Packit ae235b
Packit ae235b
Packit ae235b
(*GCacheNewFunc) ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Types and Values

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
 
Packit ae235b
GCache
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Includes

Packit ae235b
#include <gmodule.h>
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Description

Packit ae235b

A GCache allows sharing of complex data structures, in order to

Packit ae235b
save system resources.

Packit ae235b

GCache uses keys and values. A GCache key describes the properties

Packit ae235b
of a particular resource. A GCache value is the actual resource.

Packit ae235b

GCache has been marked as deprecated, since this API is rarely

Packit ae235b
used and not very actively maintained.

Packit ae235b
Packit ae235b
Packit ae235b

Functions

Packit ae235b
Packit ae235b

g_cache_new ()

Packit ae235b
GCache *
Packit ae235b
g_cache_new (GCacheNewFunc value_new_func,
Packit ae235b
             GCacheDestroyFunc value_destroy_func,
Packit ae235b
             GCacheDupFunc key_dup_func,
Packit ae235b
             GCacheDestroyFunc key_destroy_func,
Packit ae235b
             GHashFunc hash_key_func,
Packit ae235b
             GHashFunc hash_value_func,
Packit ae235b
             GEqualFunc key_equal_func);
Packit ae235b
Packit ae235b

g_cache_new has been deprecated since version 2.32 and should not be used in newly-written code.

Packit ae235b

Use a GHashTable instead

Packit ae235b
Packit ae235b

Creates a new GCache.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

value_new_func

Packit ae235b

a function to create a new object given a key.

Packit ae235b
This is called by g_cache_insert() if an object
Packit ae235b
with the given key does not already exist

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

value_destroy_func

Packit ae235b

a function to destroy an object. It is called

Packit ae235b
by g_cache_remove() when the object is no
Packit ae235b
longer needed (i.e. its reference count drops
Packit ae235b
to 0)

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

key_dup_func

Packit ae235b

a function to copy a key. It is called by

Packit ae235b
g_cache_insert() if the key does not already exist in
Packit ae235b
the GCache

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

key_destroy_func

Packit ae235b

a function to destroy a key. It is called by

Packit ae235b
g_cache_remove() when the object is no longer
Packit ae235b
needed (i.e. its reference count drops to 0)

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

hash_key_func

Packit ae235b

a function to create a hash value from a key

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

hash_value_func

Packit ae235b

a function to create a hash value from a value

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

key_equal_func

Packit ae235b

a function to compare two keys. It should return

Packit ae235b
TRUE if the two keys are equivalent

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

a new GCache

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_cache_insert ()

Packit ae235b
gpointer
Packit ae235b
g_cache_insert (GCache *cache,
Packit ae235b
                gpointer key);
Packit ae235b
Packit ae235b

g_cache_insert has been deprecated since version 2.32 and should not be used in newly-written code.

Packit ae235b

Use a GHashTable instead

Packit ae235b
Packit ae235b

Gets the value corresponding to the given key, creating it if

Packit ae235b
necessary. It first checks if the value already exists in the
Packit ae235b
GCache, by using the key_equal_func
Packit ae235b
 function passed to
Packit ae235b
g_cache_new(). If it does already exist it is returned, and its
Packit ae235b
reference count is increased by one. If the value does not currently
Packit ae235b
exist, if is created by calling the value_new_func
Packit ae235b
. The key is
Packit ae235b
duplicated by calling key_dup_func
Packit ae235b
 and the duplicated key and value
Packit ae235b
are inserted into the GCache.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cache

Packit ae235b

a GCache

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

key

Packit ae235b

a key describing a GCache object

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

a pointer to a GCache value

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_cache_remove ()

Packit ae235b
void
Packit ae235b
g_cache_remove (GCache *cache,
Packit ae235b
                gconstpointer value);
Packit ae235b
Packit ae235b

g_cache_remove has been deprecated since version 2.32 and should not be used in newly-written code.

Packit ae235b

Use a GHashTable instead

Packit ae235b
Packit ae235b

Decreases the reference count of the given value. If it drops to 0

Packit ae235b
then the value and its corresponding key are destroyed, using the
Packit ae235b
value_destroy_func
Packit ae235b
 and key_destroy_func
Packit ae235b
 passed to g_cache_new().

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cache

Packit ae235b

a GCache

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

value

Packit ae235b

the value to remove

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_cache_destroy ()

Packit ae235b
void
Packit ae235b
g_cache_destroy (GCache *cache);
Packit ae235b
Packit ae235b

g_cache_destroy has been deprecated since version 2.32 and should not be used in newly-written code.

Packit ae235b

Use a GHashTable instead

Packit ae235b
Packit ae235b

Frees the memory allocated for the GCache.

Packit ae235b

Note that it does not destroy the keys and values which were

Packit ae235b
contained in the GCache.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cache

Packit ae235b

a GCache

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_cache_key_foreach ()

Packit ae235b
void
Packit ae235b
g_cache_key_foreach (GCache *cache,
Packit ae235b
                     GHFunc func,
Packit ae235b
                     gpointer user_data);
Packit ae235b
Packit ae235b

g_cache_key_foreach has been deprecated since version 2.32 and should not be used in newly-written code.

Packit ae235b

Use a GHashTable instead

Packit ae235b
Packit ae235b

Calls the given function for each of the keys in the GCache.

Packit ae235b

NOTE func

Packit ae235b
 is passed three parameters, the value and key of a cache
Packit ae235b
entry and the user_data
Packit ae235b
. The order of value and key is different
Packit ae235b
from the order in which g_hash_table_foreach() passes key-value
Packit ae235b
pairs to its callback function !

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cache

Packit ae235b

a GCache

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

func

Packit ae235b

the function to call with each GCache key

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

user_data

Packit ae235b

user data to pass to the function

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_cache_value_foreach ()

Packit ae235b
void
Packit ae235b
g_cache_value_foreach (GCache *cache,
Packit ae235b
                       GHFunc func,
Packit ae235b
                       gpointer user_data);
Packit ae235b
Packit ae235b

g_cache_value_foreach has been deprecated since version 2.10 and should not be used in newly-written code.

Packit ae235b

The reason is that it passes pointers to internal

Packit ae235b
   data structures to func
Packit ae235b
; use g_cache_key_foreach() instead

Packit ae235b
Packit ae235b

Calls the given function for each of the values in the GCache.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cache

Packit ae235b

a GCache

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

func

Packit ae235b

the function to call with each GCache value

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

user_data

Packit ae235b

user data to pass to the function

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

GCacheDestroyFunc ()

Packit ae235b
void
Packit ae235b
(*GCacheDestroyFunc) (gpointer value);
Packit ae235b

GCacheDestroyFunc is deprecated and should not be used in newly-written code.

Packit ae235b

Specifies the type of the value_destroy_func

Packit ae235b
 and key_destroy_func
Packit ae235b
Packit ae235b
functions passed to g_cache_new(). The functions are passed a
Packit ae235b
pointer to the GCache key or GCache value and should free any
Packit ae235b
memory and other resources associated with it.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

value

Packit ae235b

the GCache value to destroy

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

GCacheDupFunc ()

Packit ae235b
gpointer
Packit ae235b
(*GCacheDupFunc) (gpointer value);
Packit ae235b

GCacheDupFunc is deprecated and should not be used in newly-written code.

Packit ae235b

Specifies the type of the key_dup_func

Packit ae235b
 function passed to
Packit ae235b
g_cache_new(). The function is passed a key
Packit ae235b
(__not__ a value as the prototype implies) and
Packit ae235b
should return a duplicate of the key.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

value

Packit ae235b

the GCache key to destroy (__not__ a

Packit ae235b
GCache value as it seems)

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

a copy of the GCache key

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

GCacheNewFunc ()

Packit ae235b
gpointer
Packit ae235b
(*GCacheNewFunc) (gpointer key);
Packit ae235b

GCacheNewFunc is deprecated and should not be used in newly-written code.

Packit ae235b

Specifies the type of the value_new_func

Packit ae235b
 function passed to
Packit ae235b
g_cache_new(). It is passed a GCache key and should create the
Packit ae235b
value corresponding to the key.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

key

Packit ae235b

a GCache key

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

a new GCache value corresponding to the key.

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Types and Values

Packit ae235b
Packit ae235b

GCache

Packit ae235b
typedef struct _GCache GCache;
Packit ae235b
Packit ae235b

GCache has been deprecated since version 2.32 and should not be used in newly-written code.

Packit ae235b

Use a GHashTable instead

Packit ae235b
Packit ae235b

The GCache struct is an opaque data structure containing

Packit ae235b
information about a GCache. It should only be accessed via the
Packit ae235b
following functions.

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Generated by GTK-Doc V1.27
Packit ae235b
</body>
Packit ae235b
</html>