1
/* Copyright (c) 2005 PrimeBase Technologies GmbH
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
* 2005-02-03 Paul McCullagh
23
#ifndef __xt_linklist_h__
24
#define __xt_linklist_h__
30
typedef struct XTLinkedItem {
31
struct XTLinkedItem *li_prev;
32
struct XTLinkedItem *li_next;
33
} XTLinkedItemRec, *XTLinkedItemPtr;
35
typedef struct XTLinkedList {
36
xt_mutex_type *ll_lock;
37
xt_cond_type *ll_cond; /* Condition for wait for empty. */
39
XTFreeFunc ll_free_func;
41
XTLinkedItemPtr ll_items;
42
} XTLinkedListRec, *XTLinkedListPtr;
44
XTLinkedListPtr xt_new_linkedlist(struct XTThread *self, void *thunk, XTFreeFunc free_func, xtBool with_lock);
45
void xt_free_linkedlist(struct XTThread *self, XTLinkedListPtr ll);
47
void xt_ll_add(struct XTThread *self, XTLinkedListPtr ll, XTLinkedItemPtr li, xtBool lock);
48
void xt_ll_remove(struct XTThread *self, XTLinkedListPtr ll, XTLinkedItemPtr li, xtBool lock);
49
xtBool xt_ll_exists(struct XTThread *self, XTLinkedListPtr ll, XTLinkedItemPtr li, xtBool lock);
51
void xt_ll_lock(struct XTThread *self, XTLinkedListPtr ll);
52
void xt_ll_unlock(struct XTThread *self, XTLinkedListPtr ll);
54
void xt_ll_wait_till_empty(struct XTThread *self, XTLinkedListPtr ll);
56
XTLinkedItemPtr xt_ll_first_item(struct XTThread *self, XTLinkedListPtr ll);
57
XTLinkedItemPtr xt_ll_next_item(struct XTThread *self, XTLinkedItemPtr item);
58
u_int xt_ll_get_size(XTLinkedListPtr ll);
60
typedef struct XTLinkedQItem {
61
struct XTLinkedQItem *qi_next;
62
} XTLinkedQItemRec, *XTLinkedQItemPtr;
64
typedef struct XTLinkedQueue {
66
XTLinkedQItemPtr lq_front;
67
XTLinkedQItemPtr lq_back;
68
} XTLinkedQueueRec, *XTLinkedQueuePtr;
70
void xt_init_linkedqueue(struct XTThread *self, XTLinkedQueuePtr lq);
71
void xt_exit_linkedqueue(struct XTThread *self, XTLinkedQueuePtr lq);
73
void xt_lq_add(struct XTThread *self, XTLinkedQueuePtr lq, XTLinkedQItemPtr qi);
74
XTLinkedQItemPtr xt_lq_remove(struct XTThread *self, XTLinkedQueuePtr lq);