source: trunk/minix/servers/inet/generic/event.c@ 20

Last change on this file since 20 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 944 bytes
RevLine 
[9]1/*
2inet/generic/event.c
3
4Created: April 1995 by Philip Homburg <philip@f-mnx.phicoh.com>
5
6Implementation of an event queue.
7
8Copyright 1995 Philip Homburg
9*/
10
11#include "inet.h"
12#include "assert.h"
13#include "event.h"
14
15THIS_FILE
16
17event_t *ev_head;
18static event_t *ev_tail;
19
20void ev_init(ev)
21event_t *ev;
22{
23 ev->ev_func= 0;
24 ev->ev_next= NULL;
25}
26
27void ev_enqueue(ev, func, ev_arg)
28event_t *ev;
29ev_func_t func;
30ev_arg_t ev_arg;
31{
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;
41}
42
43void ev_process()
44{
45 ev_func_t func;
46 event_t *curr;
47
48 while (ev_head)
49 {
50 curr= ev_head;
51 ev_head= curr->ev_next;
52 func= curr->ev_func;
53 curr->ev_func= 0;
54
55 assert(func != 0);
56 func(curr, curr->ev_arg);
57 }
58}
59
60int ev_in_queue(ev)
61event_t *ev;
62{
63 return ev->ev_func != 0;
64}
65
66
67/*
68 * $PchId: event.c,v 1.6 2004/08/03 16:23:32 philip Exp $
69 */
Note: See TracBrowser for help on using the repository browser.