2 * Thread management routine header.
3 * Copyright (C) 1998 Kunihiro Ishiguro
5 * This file is part of GNU Zebra.
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23 #ifndef _ZEBRA_THREAD_H
24 #define _ZEBRA_THREAD_H
26 /* Linked list of thread. */
34 /* Master of the theads. */
37 struct thread_list read
;
38 struct thread_list write
;
39 struct thread_list timer
;
40 struct thread_list event
;
41 struct thread_list ready
;
42 struct thread_list unuse
;
53 unsigned char type
; /* thread type */
54 struct thread
*next
; /* next pointer of the thread */
55 struct thread
*prev
; /* previous pointer of the thread */
56 struct thread_master
*master
; /* pointer to the struct thread_master. */
57 int (*func
) (struct thread
*); /* event function */
58 void *arg
; /* event argument */
60 int val
; /* second argument of the event. */
61 int fd
; /* file descriptor in case of read/write. */
62 struct timeval sands
; /* rest of time sands value. */
67 #define THREAD_ARG(X) ((X)->arg)
68 #define THREAD_FD(X) ((X)->u.fd)
69 #define THREAD_VAL(X) ((X)->u.val)
72 struct thread_master
*thread_make_master ();
75 thread_add_read (struct thread_master
*m
,
76 int (*func
)(struct thread
*),
81 thread_add_write (struct thread_master
*m
,
82 int (*func
)(struct thread
*),
87 thread_add_timer (struct thread_master
*m
,
88 int (*func
)(struct thread
*),
93 thread_add_event (struct thread_master
*m
,
94 int (*func
)(struct thread
*),
99 thread_cancel (struct thread
*thread
);
102 thread_cancel_event (struct thread_master
*m
, void *arg
);
105 thread_fetch (struct thread_master
*m
,
106 struct thread
*fetch
);
109 thread_call (struct thread
*thread
);
112 thread_execute (struct thread_master
*m
,
113 int (*func
)(struct thread
*),
117 #endif /* _ZEBRA_THREAD_H */