Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

aging.c File Reference


Detailed Description

Hash table with aging values, removed automatically after some time has elapsed.

Author:
Raphael Manfredi
Date:
2004

#include "common.h"
#include "aging.h"
#include "cq.h"
#include "misc.h"
#include "tm.h"
#include "walloc.h"
#include "override.h"

Data Structures

struct  aging
struct  aging_value
 We wrap the values we insert in the table, since each value must keep track of its insertion time, and cleanup event. More...

Enumerations

enum  aging_magic { AGING_MAGIC = 0xb8e2fac3U }
 The hash table is the central piece, but we also have a `value freeing' callback, since the values can expire automatically. More...

Functions

agingaging_make (gint delay, GHashFunc hash, GEqualFunc eq, aging_free_t kfree)
 Create new aging container.
void aging_free_kv (gpointer key, gpointer value, gpointer udata)
 Free keys and values from the aging table.
void aging_destroy (struct aging *ag)
 Destroy container, freeing all keys and values.
void aging_expire (cqueue_t *unused_cq, gpointer obj)
 Expire value entry.
gpointer aging_lookup (struct aging *ag, gpointer key)
 Lookup value in table.
void aging_remove (struct aging *ag, gpointer key)
 Remove value associated with key, dispose of items (key and value) stored in the hash table, but leave the function parameter alone.
void aging_insert (struct aging *ag, gpointer key, gpointer value)
 Add value to the table.


Enumeration Type Documentation

enum aging_magic
 

The hash table is the central piece, but we also have a `value freeing' callback, since the values can expire automatically.

Enumeration values:
AGING_MAGIC 


Function Documentation

void aging_destroy struct aging ag  ) 
 

Destroy container, freeing all keys and values.

void aging_expire cqueue_t unused_cq,
gpointer  obj
[static]
 

Expire value entry.

void aging_free_kv gpointer  key,
gpointer  value,
gpointer  udata
[static]
 

Free keys and values from the aging table.

void aging_insert struct aging ag,
gpointer  key,
gpointer  value
 

Add value to the table.

If it was already present, its lifetime is augmented by the aging delay.

The key argument is freed immediately if there is a free routine for keys and the key was present in the table.

The previous value is freed and replaced by the new one if there is an insertion conflict and the value pointers are different.

gpointer aging_lookup struct aging ag,
gpointer  key
 

Lookup value in table.

struct aging* aging_make gint  delay,
GHashFunc  hash,
GEqualFunc  eq,
aging_free_t  kfree
 

Create new aging container.

Parameters:
delay the aging delay, in seconds, for entries
hash the hashing function for the keys in the hash table
eq the equality function for the keys in the hash table
kfree the key freeing callback, NULL if none.
Returns:
opaque handle to the container.

void aging_remove struct aging ag,
gpointer  key
 

Remove value associated with key, dispose of items (key and value) stored in the hash table, but leave the function parameter alone.


Generated on Sat Jun 30 17:53:25 2007 for gtk-gnutella by  doxygen 1.3.9.1