summaryrefslogtreecommitdiff
path: root/src/dict.h
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2011-05-10 10:15:50 +0200
committerantirez <antirez@gmail.com>2011-05-10 10:15:50 +0200
commit4b53e7365c647235bbb3909596a7defe50709b67 (patch)
treec618e85e97ea33b45703adb125bed92118a726c1 /src/dict.h
parentf13cb0d9de088898cd879b3912ea3e3300fc9fdf (diff)
downloadredis-4b53e7365c647235bbb3909596a7defe50709b67.tar.gz
Introduced a safe iterator interface that can be used to iterate while accessing the dictionary at the same time. Now the default interface is consireded unsafe and should be used only with dictNext()
Diffstat (limited to 'src/dict.h')
-rw-r--r--src/dict.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/dict.h b/src/dict.h
index 25cce4e50..74bcd2aad 100644
--- a/src/dict.h
+++ b/src/dict.h
@@ -74,10 +74,13 @@ typedef struct dict {
int iterators; /* number of iterators currently running */
} dict;
+/* If safe is set to 1 this is a safe iteartor, that means, you can call
+ * dictAdd, dictFind, and other functions against the dictionary even while
+ * iterating. Otherwise it is a non safe iterator, and only dictNext()
+ * should be called while iterating. */
typedef struct dictIterator {
dict *d;
- int table;
- int index;
+ int table, index, safe;
dictEntry *entry, *nextEntry;
} dictIterator;
@@ -132,6 +135,7 @@ dictEntry * dictFind(dict *d, const void *key);
void *dictFetchValue(dict *d, const void *key);
int dictResize(dict *d);
dictIterator *dictGetIterator(dict *d);
+dictIterator *dictGetSafeIterator(dict *d);
dictEntry *dictNext(dictIterator *iter);
void dictReleaseIterator(dictIterator *iter);
dictEntry *dictGetRandomKey(dict *d);