event.h 855 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 *	BIRD Library -- Event Processing
 *
 *	(c) 1999 Martin Mares <mj@ucw.cz>
 *
 *	Can be freely distributed and used under the terms of the GNU GPL.
 */

#ifndef _BIRD_EVENT_H_
#define _BIRD_EVENT_H_

#include "lib/resource.h"

typedef struct event {
  resource r;
16
  void (*hook)(void *);
17 18 19 20 21 22 23 24 25
  void *data;
  node n;				/* Internal link */
} event;

typedef list event_list;

extern event_list global_event_list;

event *ev_new(pool *);
26
void ev_run(event *);
27 28 29 30
#define ev_init_list(el) init_list(el)
void ev_enqueue(event_list *, event *);
void ev_schedule(event *);
void ev_postpone(event *);
31
int ev_run_list(event_list *);
32

33 34 35 36 37 38
static inline int
ev_active(event *e)
{
  return e->n.next != NULL;
}

39 40 41 42 43 44 45 46 47
static inline event*
ev_new_init(pool *p, void (*hook)(void *), void *data)
{
  event *e = ev_new(p);
  e->hook = hook;
  e->data = data;
  return e;
}

48

49
#endif