Cache

Description A GCache allows sharing of complex data structures, in order to save system resources. GTK+ uses caches for GtkStyles and GdkGCs. These consume a lot of resources, so a GCache is used to see if a GtkStyle or GdkGC with the required properties already exists. If it does, then the existing object is used instead of creating a new one. GCache uses keys and values. A GCache key describes the properties of a particular resource. A GCache value is the actual resource.

Constructors

this
this(GCache* gCache)

Sets our main struct and passes it to the parent class

this
this(GCacheNewFunc valueNewFunc, GCacheDestroyFunc valueDestroyFunc, GCacheDupFunc keyDupFunc, GCacheDestroyFunc keyDestroyFunc, GHashFunc hashKeyFunc, GHashFunc hashValueFunc, GEqualFunc keyEqualFunc)

Creates a new GCache.

Members

Functions

destroy
void destroy()

Frees the memory allocated for the GCache. Note that it does not destroy the keys and values which were contained in the GCache.

getCacheStruct
GCache* getCacheStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getStruct
void* getStruct()

the main Gtk struct as a void*

insert
void* insert(void* key)

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

keyForeach
void keyForeach(GHFunc func, void* userData)

Calls the given function for each of the keys in the GCache. NOTE func is passed three parameters, the value and key of a cache entry and the user_data. The order of value and key is different from the order in which g_hash_table_foreach() passes key-value pairs to its callback function !

remove
void remove(void* value)

Decreases the reference count of the given value. If it drops to 0 then the value and its corresponding key are destroyed, using the value_destroy_func and key_destroy_func passed to g_cache_new().

valueForeach
void valueForeach(GHFunc func, void* userData)

Warning g_cache_value_foreach has been deprecated since version 2.10 and should not be used in newly-written code. The reason is that it passes pointers to internal data structures to func; use g_cache_key_foreach() instead Calls the given function for each of the values in the GCache.

Variables

gCache
GCache* gCache;

the main Gtk struct

Meta