1999-02-12 06:18:36 +08:00
|
|
|
/*
|
|
|
|
* 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;
|
2000-04-28 06:28:49 +08:00
|
|
|
void (*hook)(void *);
|
1999-02-12 06:18:36 +08:00
|
|
|
void *data;
|
|
|
|
node n; /* Internal link */
|
|
|
|
} event;
|
|
|
|
|
|
|
|
typedef list event_list;
|
|
|
|
|
|
|
|
extern event_list global_event_list;
|
|
|
|
|
|
|
|
event *ev_new(pool *);
|
2000-04-28 06:28:49 +08:00
|
|
|
void ev_run(event *);
|
1999-02-12 06:18:36 +08:00
|
|
|
#define ev_init_list(el) init_list(el)
|
|
|
|
void ev_enqueue(event_list *, event *);
|
|
|
|
void ev_schedule(event *);
|
|
|
|
void ev_postpone(event *);
|
1999-11-17 20:01:11 +08:00
|
|
|
int ev_run_list(event_list *);
|
1999-02-12 06:18:36 +08:00
|
|
|
|
2014-11-03 17:42:55 +08:00
|
|
|
static inline int
|
|
|
|
ev_active(event *e)
|
|
|
|
{
|
|
|
|
return e->n.next != NULL;
|
|
|
|
}
|
|
|
|
|
2018-10-01 21:55:23 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-11-03 17:42:55 +08:00
|
|
|
|
1999-02-12 06:18:36 +08:00
|
|
|
#endif
|