-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathloop.h
52 lines (38 loc) · 940 Bytes
/
loop.h
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
#ifndef __LOOP_H__
#define __LOOP_H__
enum {
LOOP_OK = 0,
LOOP_ERR = -1
};
enum {
LOOP_EOF = 1 << 0,
LOOP_READ = 1 << 1,
LOOP_WRITE = 1 << 2,
LOOP_ERROR = 1 << 3,
};
enum {
LOOP_FLAGS_REPEAT = 1 << 0,
LOOP_FLAGS_ABSOLUTE = 1 << 1,
LOOP_FLAGS_INVALID = 1 << 2,
};
typedef struct loop loop_t;
typedef void loop_proc_t(loop_t *loop, int id, int tag, int type, int flag, void *args);
loop_t *
loop_open(int event_max, int timer_max);
void
loop_close(loop_t *loop);
int
loop_set_event(loop_t *loop, int fd, int tag, int type, int flag,
loop_proc_t *proc, void *args);
int
loop_del_event(loop_t *loop, int fd, int type);
int
loop_set_timer(loop_t *loop, int id, int tag, int type, int flag,
long seconds, int nanoseconds, loop_proc_t *proc, void *args);
int
loop_del_timer(loop_t *loop, int id, int tag, int type);
int
loop_start(loop_t *loop);
int
loop_stop(loop_t *loop);
#endif /* __LOOP_H__ */