opendir change: refinement
[minix.git] / servers / inet / generic / event.c
blobe59d97706f062fe972104eb3c99d084df800032c
1 /*
2 inet/generic/event.c
4 Created: April 1995 by Philip Homburg <philip@f-mnx.phicoh.com>
6 Implementation of an event queue.
8 Copyright 1995 Philip Homburg
9 */
11 #include "inet.h"
12 #include "assert.h"
13 #include "event.h"
15 THIS_FILE
17 event_t *ev_head;
18 static event_t *ev_tail;
20 void ev_init(ev)
21 event_t *ev;
23 ev->ev_func= 0;
24 ev->ev_next= NULL;
27 void ev_enqueue(ev, func, ev_arg)
28 event_t *ev;
29 ev_func_t func;
30 ev_arg_t ev_arg;
32 assert(ev->ev_func == 0);
33 ev->ev_func= func;
34 ev->ev_arg= ev_arg;
35 ev->ev_next= NULL;
36 if (ev_head == NULL)
37 ev_head= ev;
38 else
39 ev_tail->ev_next= ev;
40 ev_tail= ev;
43 void ev_process()
45 ev_func_t func;
46 event_t *curr;
48 while (ev_head)
50 curr= ev_head;
51 ev_head= curr->ev_next;
52 func= curr->ev_func;
53 curr->ev_func= 0;
55 assert(func != 0);
56 func(curr, curr->ev_arg);
60 int ev_in_queue(ev)
61 event_t *ev;
63 return ev->ev_func != 0;
68 * $PchId: event.c,v 1.6 2004/08/03 16:23:32 philip Exp $