2017-05-24 11:57:15 +00:00
|
|
|
#ifndef OD_LIST_H
|
|
|
|
#define OD_LIST_H
|
|
|
|
|
|
|
|
/*
|
2017-07-05 12:42:49 +00:00
|
|
|
* Odissey.
|
2017-05-24 11:57:15 +00:00
|
|
|
*
|
2017-07-05 12:42:49 +00:00
|
|
|
* Advanced PostgreSQL connection pooler.
|
2017-05-24 11:57:15 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct od_list od_list_t;
|
|
|
|
|
|
|
|
struct od_list
|
|
|
|
{
|
|
|
|
od_list_t *next, *prev;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void
|
2017-05-24 12:13:44 +00:00
|
|
|
od_list_init(od_list_t *list)
|
2017-05-24 11:57:15 +00:00
|
|
|
{
|
|
|
|
list->next = list->prev = list;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2017-05-24 12:13:44 +00:00
|
|
|
od_list_append(od_list_t *list, od_list_t *node)
|
2017-05-24 11:57:15 +00:00
|
|
|
{
|
|
|
|
node->next = list;
|
|
|
|
node->prev = list->prev;
|
|
|
|
node->prev->next = node;
|
|
|
|
node->next->prev = node;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2017-05-24 12:13:44 +00:00
|
|
|
od_list_unlink(od_list_t *node)
|
2017-05-24 11:57:15 +00:00
|
|
|
{
|
|
|
|
node->prev->next = node->next;
|
|
|
|
node->next->prev = node->prev;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2017-05-24 12:13:44 +00:00
|
|
|
od_list_push(od_list_t *list, od_list_t *node)
|
2017-05-24 11:57:15 +00:00
|
|
|
{
|
|
|
|
node->next = list->next;
|
|
|
|
node->prev = list;
|
|
|
|
node->prev->next = node;
|
|
|
|
node->next->prev = node;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline od_list_t*
|
2017-05-24 12:13:44 +00:00
|
|
|
od_list_pop(od_list_t *list)
|
2017-05-24 11:57:15 +00:00
|
|
|
{
|
|
|
|
register od_list_t *pop = list->next;
|
2017-05-24 12:13:44 +00:00
|
|
|
od_list_unlink(pop);
|
2017-05-24 11:57:15 +00:00
|
|
|
return pop;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
2017-05-24 12:13:44 +00:00
|
|
|
od_list_empty(od_list_t *list)
|
2017-05-24 11:57:15 +00:00
|
|
|
{
|
|
|
|
return list->next == list && list->prev == list;
|
|
|
|
}
|
|
|
|
|
2017-05-24 12:13:44 +00:00
|
|
|
#define od_list_foreach(LIST, I) \
|
2017-05-24 11:57:15 +00:00
|
|
|
for (I = (LIST)->next; I != LIST; I = (I)->next)
|
|
|
|
|
2017-05-24 12:13:44 +00:00
|
|
|
#define od_list_foreach_safe(LIST, I, N) \
|
2017-05-24 11:57:15 +00:00
|
|
|
for (I = (LIST)->next; I != LIST && (N = I->next); I = N)
|
|
|
|
|
|
|
|
#endif /* OD_LIST_H */
|