Process async client checks like client timeouts and BLPOP timeouts incrementally using a circular list.

This commit is contained in:
antirez
2012-03-13 18:05:11 +01:00
parent bbaeda402c
commit d19015be12
4 changed files with 63 additions and 31 deletions

View File

@ -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;
}