diff options
author | antirez <antirez@gmail.com> | 2012-03-13 18:05:11 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2012-03-13 18:05:11 +0100 |
commit | d19015be12c98f329cdaab039b843c3bf8931916 (patch) | |
tree | 01fcdd4f92149496e39a9c80c3a493ca7175090b /src/adlist.c | |
parent | bbaeda402cac1b66b52a869bfc419001d79ffcc0 (diff) | |
download | redis-d19015be12c98f329cdaab039b843c3bf8931916.tar.gz |
Process async client checks like client timeouts and BLPOP timeouts incrementally using a circular list.
Diffstat (limited to 'src/adlist.c')
-rw-r--r-- | src/adlist.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/adlist.c b/src/adlist.c index 51ba03bd5..e48957e3a 100644 --- a/src/adlist.c +++ b/src/adlist.c @@ -323,3 +323,19 @@ listNode *listIndex(list *list, long index) { } return n; } + +/* Rotate the list removing the tail node and inserting it to the head. */ +void listRotate(list *list) { + listNode *tail = list->tail; + + if (listLength(list) <= 1) return; + + /* Detatch current tail */ + list->tail = tail->prev; + list->tail->next = NULL; + /* Move it as head */ + list->head->prev = tail; + tail->prev = NULL; + tail->next = list->head; + list->head = tail; +} |