Main Page | Modules | Alphabetical List | Data Structures | 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...


Defines

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


Functions

 RCSID ("$Id:aging.c, v 1.9 2005/08/31 21:37:32 rmanfredi Exp $")
gpointer aging_make (gint delay, GHashFunc hash, GEqualFunc eq, aging_free_t kfree, gpointer kdata, aging_free_t vfree, gpointer vdata)
 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 (gpointer obj)
 Destroy container, freeing all keys and values.

void aging_expire (cqueue_t *unused_cq, gpointer obj)
 Expire value entry.

gpointer aging_lookup (gpointer obj, gpointer key)
 Lookup value in table.

void aging_remove (gpointer obj, 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 (gpointer obj, gpointer key, gpointer value)
 Add value to the table.


Define Documentation

#define AGING_MAGIC   0xa9179
 

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


Function Documentation

void aging_destroy gpointer  obj  ) 
 

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 gpointer  obj,
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 gpointer  obj,
gpointer  key
 

Lookup value in table.

gpointer aging_make gint  delay,
GHashFunc  hash,
GEqualFunc  eq,
aging_free_t  kfree,
gpointer  kdata,
aging_free_t  vfree,
gpointer  vdata
 

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.
kdata the extra parameter to pass to the key-freeing callback
vfree the value freeing callback, NULL if none.
vdata the extra parameter to pass to the value-freeing callback
Returns:
opaque handle to the container.

void aging_remove gpointer  obj,
gpointer  key
 

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

RCSID "$Id:aging.  c,
v 1.9 2005/08/31 21:37:32 rmanfredi Exp $" 
 


Generated on Sun Feb 12 10:49:59 2006 for Gtk-Gnutella by doxygen 1.3.6