File: event.h

package info (click to toggle)
proxycheck 0.49a-4
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, lenny, squeeze, wheezy
  • size: 252 kB
  • ctags: 326
  • sloc: sh: 2,878; ansic: 2,616; makefile: 100
file content (85 lines) | stat: -rw-r--r-- 2,235 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* $Id: event.h,v 1.7 2004/05/29 14:26:24 mjt Exp $
 * Timer and I/O Event header
 * Author: Michael Tokarev <mjt@corpit.ru>
 * Licence: LGPL.
 */

#ifndef _EVENT_H
#define _EVENT_H

#include <sys/types.h>

struct ev_ct;
struct ev_tm;

typedef long long ev_time_t;

#define EV_SELECT	0x01
#define EV_POLL		0x02
#define EV_EPOLL	0x04
#define EV_KQUEUE	0x08
#define EV_DEVPOLL	0x10
#define EV_ADVANCED	(EV_EPOLL|EV_KQUEUE|EV_DEVPOLL)

int ev_init(int maxfdhint, int type);
void ev_free(void);

struct ev_ct *ev_ct_new(int maxfdhint, int type);
void ev_ct_free(struct ev_ct *ct);

const char *ev_method_name(const struct ev_ct *ct);
int ev_method(const struct ev_ct *ct);

int ev_wait(struct ev_ct *ct, int timeout);

ev_time_t ev_gettime(void);
extern ev_time_t ev_now;
extern time_t ev_time;

int ev_fdlimit(void);

/* waiting for I/O */

#define EV_IN	0x01
#define EV_PRI	0x02
#define EV_OUT	0x04

typedef void ev_io_cbck_f(void *data, int revents, int fd, struct ev_ct *ct);

int ev_io_add(struct ev_ct *ct, int fd, int events,
              ev_io_cbck_f *cb, void *data);
int ev_io_mod(struct ev_ct *ct, int fd, int events,
              ev_io_cbck_f *cb, void *data);
int ev_io_del(struct ev_ct *ct, int fd);
int ev_io_count(const struct ev_ct *ct);

/* timers */
typedef void ev_tm_cbck_f(void *data, struct ev_tm *tmr, struct ev_ct *ct);

struct ev_tm {
  struct ev_tm *evtm_prev, *evtm_next;
  ev_time_t evtm_when;
  ev_tm_cbck_f *evtm_cbck;
  void *evtm_data;
};

struct ev_tm *
ev_tm_add(struct ev_ct *ct, struct ev_tm *tmr,
          int mstimeout, ev_tm_cbck_f *cb, void *data);
struct ev_tm *
ev_ts_add(struct ev_ct *ct, struct ev_tm *tmr,
          int stimeout, ev_tm_cbck_f *cb, void *data);
int ev_tm_del(struct ev_ct *ct, struct ev_tm *tmr);
int ev_tm_count(const struct ev_ct *ct);
ev_time_t ev_tm_first(const struct ev_ct *ct);
int ev_tm_timeout(const struct ev_ct *ct);

#if 0
typedef void ev_sig_cbck_f(void *data, int sig, struct ev_ct *ct);
int ev_sig_add(struct ev_ct *ct, int sig, ev_sig_cbck_f *cbck, void *data);
int ev_sig_mod(struct ev_ct *ct, int sig, ev_sig_cbck_f *cbck, void *data);
int ev_sig_del(struct ev_ct *ct, int sig);
int ev_sig_count(const struct ev_ct *ct);
#endif

#endif /* include guard */