xref: /PHP-5.5/sapi/fpm/fpm/fpm_events.h (revision e7c6f9c6)
1 
2 	/* $Id: fpm_events.h,v 1.9 2008/05/24 17:38:47 anight Exp $ */
3 	/* (c) 2007,2008 Andrei Nigmatulin */
4 
5 #ifndef FPM_EVENTS_H
6 #define FPM_EVENTS_H 1
7 
8 #define FPM_EV_TIMEOUT  (1 << 0)
9 #define FPM_EV_READ     (1 << 1)
10 #define FPM_EV_PERSIST  (1 << 2)
11 #define FPM_EV_EDGE     (1 << 3)
12 
13 #define fpm_event_set_timer(ev, flags, cb, arg) fpm_event_set((ev), -1, (flags), (cb), (arg))
14 
15 struct fpm_event_s {
16 	int fd;                   /* not set with FPM_EV_TIMEOUT */
17 	struct timeval timeout;   /* next time to trigger */
18 	struct timeval frequency;
19 	void (*callback)(struct fpm_event_s *, short, void *);
20 	void *arg;
21 	int flags;
22 	int index;                /* index of the fd in the ufds array */
23 	short which;              /* type of event */
24 };
25 
26 typedef struct fpm_event_queue_s {
27 	struct fpm_event_queue_s *prev;
28 	struct fpm_event_queue_s *next;
29 	struct fpm_event_s *ev;
30 } fpm_event_queue;
31 
32 struct fpm_event_module_s {
33 	const char *name;
34 	int support_edge_trigger;
35 	int (*init)(int max_fd);
36 	int (*clean)(void);
37 	int (*wait)(struct fpm_event_queue_s *queue, unsigned long int timeout);
38 	int (*add)(struct fpm_event_s *ev);
39 	int (*remove)(struct fpm_event_s *ev);
40 };
41 
42 void fpm_event_loop(int err);
43 void fpm_event_fire(struct fpm_event_s *ev);
44 int fpm_event_init_main();
45 int fpm_event_set(struct fpm_event_s *ev, int fd, int flags, void (*callback)(struct fpm_event_s *, short, void *), void *arg);
46 int fpm_event_add(struct fpm_event_s *ev, unsigned long int timeout);
47 int fpm_event_del(struct fpm_event_s *ev);
48 int fpm_event_pre_init(char *machanism);
49 const char *fpm_event_machanism_name();
50 int fpm_event_support_edge_trigger();
51 
52 #endif
53