aboutsummaryrefslogtreecommitdiffstats
path: root/e-util/e-msgport.h
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-01-14 13:04:04 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-01-14 13:04:04 +0800
commit18b15bfc5ae50a909621c7ea3e00e6f8ff7b4808 (patch)
tree72e9a61666b1809b3ce21f30b6ec93d5806e6528 /e-util/e-msgport.h
parent7fdc703916b8d40398f16d205e953867015d2bac (diff)
downloadgsoc2013-evolution-18b15bfc5ae50a909621c7ea3e00e6f8ff7b4808.tar.gz
gsoc2013-evolution-18b15bfc5ae50a909621c7ea3e00e6f8ff7b4808.tar.zst
gsoc2013-evolution-18b15bfc5ae50a909621c7ea3e00e6f8ff7b4808.zip
A time-based thread-safe in-memory cache thing. Called em_cache 'cause
2004-01-13 Not Zed <NotZed@Ximian.com> * e-msgport.c (em_cache*): A time-based thread-safe in-memory cache thing. Called em_cache 'cause there's an e_cache in gal. svn path=/trunk/; revision=24213
Diffstat (limited to 'e-util/e-msgport.h')
-rw-r--r--e-util/e-msgport.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/e-util/e-msgport.h b/e-util/e-msgport.h
index 8d4e0c20f7..6347564c0f 100644
--- a/e-util/e-msgport.h
+++ b/e-util/e-msgport.h
@@ -2,6 +2,9 @@
#ifndef _E_MSGPORT_H
#define _E_MSGPORT_H
+#include <time.h>
+#include <glib.h>
+
/* double-linked list yeah another one, deal */
typedef struct _EDListNode {
struct _EDListNode *next;
@@ -25,6 +28,26 @@ EDListNode *e_dlist_remtail(EDList *l);
int e_dlist_empty(EDList *l);
int e_dlist_length(EDList *l);
+/* a time-based cache */
+typedef struct _EMCache EMCache;
+typedef struct _EMCacheNode EMCacheNode;
+
+/* subclass this for your data nodes, EMCache is opaque */
+struct _EMCacheNode {
+ struct _EMCacheNode *next, *prev;
+ char *key;
+ int ref_count;
+ time_t stamp;
+};
+
+EMCache *em_cache_new(time_t timeout, size_t nodesize, GFreeFunc nodefree);
+void em_cache_destroy(EMCache *emc);
+EMCacheNode *em_cache_lookup(EMCache *emc, const char *key);
+EMCacheNode *em_cache_node_new(EMCache *emc, const char *key);
+void em_cache_node_unref(EMCache *emc, EMCacheNode *n);
+void em_cache_add(EMCache *emc, EMCacheNode *n);
+void em_cache_clear(EMCache *emc);
+
/* message ports - a simple inter-thread 'ipc' primitive */
/* opaque handle */
typedef struct _EMsgPort EMsgPort;