123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- #ifndef _THREADLIST_H_
- #define _THREADLIST_H_
- struct thread;
- struct threadlistnode {
- struct threadlistnode *tln_prev;
- struct threadlistnode *tln_next;
- struct thread *tln_self;
- };
- struct threadlist {
- struct threadlistnode tl_head;
- struct threadlistnode tl_tail;
- unsigned tl_count;
- };
- void threadlistnode_init(struct threadlistnode *tln, struct thread *self);
- void threadlistnode_cleanup(struct threadlistnode *tln);
- void threadlist_init(struct threadlist *tl);
- void threadlist_cleanup(struct threadlist *tl);
- bool threadlist_isempty(struct threadlist *tl);
- void threadlist_addhead(struct threadlist *tl, struct thread *t);
- void threadlist_addtail(struct threadlist *tl, struct thread *t);
- struct thread *threadlist_remhead(struct threadlist *tl);
- struct thread *threadlist_remtail(struct threadlist *tl);
- void threadlist_insertafter(struct threadlist *tl,
- struct thread *onlist, struct thread *addee);
- void threadlist_insertbefore(struct threadlist *tl,
- struct thread *addee, struct thread *onlist);
- void threadlist_remove(struct threadlist *tl, struct thread *t);
- #define THREADLIST_FORALL(itervar, tl) \
- for ((itervar) = (tl).tl_head.tln_next->tln_self; \
- (itervar)->t_listnode.tln_next != NULL; \
- (itervar) = (itervar)->t_listnode.tln_next->tln_self)
- #define THREADLIST_FORALL_REV(itervar, tl) \
- for ((itervar) = (tl).tl_tail.tln_prev->tln_self; \
- (itervar)->t_listnode.tln_prev != NULL; \
- (itervar) = (itervar)->t_listnode.tln_prev->tln_self)
- #endif
|