Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/lib/ioloop.h @ 3863:55df57c028d4 HEAD
Added "bool" type and changed all ints that were used as booleans to bool.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 13 Jan 2006 22:25:57 +0200 |
parents | be1bac1dd005 |
children | 928229f8b3e6 |
rev | line source |
---|---|
0 | 1 #ifndef __IOLOOP_H |
2 #define __IOLOOP_H | |
3 | |
1431
8a2e1c539faf
struct timeval requires sys/time.h
Timo Sirainen <tss@iki.fi>
parents:
1036
diff
changeset
|
4 #include <sys/time.h> |
0 | 5 #include <time.h> |
6 | |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
492
diff
changeset
|
7 struct io; |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
492
diff
changeset
|
8 struct timeout; |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
492
diff
changeset
|
9 struct ioloop; |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
492
diff
changeset
|
10 |
1729
5bf22d6bb65e
Added IO_DIR_NOTIFY and IO_FILE_NOTIFY conditions to io_add(). IO_DIR_NOTIFY
Timo Sirainen <tss@iki.fi>
parents:
1499
diff
changeset
|
11 enum io_condition { |
5bf22d6bb65e
Added IO_DIR_NOTIFY and IO_FILE_NOTIFY conditions to io_add(). IO_DIR_NOTIFY
Timo Sirainen <tss@iki.fi>
parents:
1499
diff
changeset
|
12 IO_READ = 0x01, |
5bf22d6bb65e
Added IO_DIR_NOTIFY and IO_FILE_NOTIFY conditions to io_add(). IO_DIR_NOTIFY
Timo Sirainen <tss@iki.fi>
parents:
1499
diff
changeset
|
13 IO_WRITE = 0x02, |
3613
c4c1b538d8d0
Added IO_ERROR condition that we can watch now.
Timo Sirainen <tss@iki.fi>
parents:
3534
diff
changeset
|
14 IO_ERROR = 0x04, |
3534
a9be1824403b
New inotify code and notify API change. Patch by Johannes Berg
Timo Sirainen <tss@iki.fi>
parents:
1729
diff
changeset
|
15 |
a9be1824403b
New inotify code and notify API change. Patch by Johannes Berg
Timo Sirainen <tss@iki.fi>
parents:
1729
diff
changeset
|
16 /* internal */ |
a9be1824403b
New inotify code and notify API change. Patch by Johannes Berg
Timo Sirainen <tss@iki.fi>
parents:
1729
diff
changeset
|
17 IO_NOTIFY = 0x04, |
1729
5bf22d6bb65e
Added IO_DIR_NOTIFY and IO_FILE_NOTIFY conditions to io_add(). IO_DIR_NOTIFY
Timo Sirainen <tss@iki.fi>
parents:
1499
diff
changeset
|
18 }; |
5bf22d6bb65e
Added IO_DIR_NOTIFY and IO_FILE_NOTIFY conditions to io_add(). IO_DIR_NOTIFY
Timo Sirainen <tss@iki.fi>
parents:
1499
diff
changeset
|
19 |
1036
f782b3319553
Removed useless parameters from io_callback_t and timeout_callback_t.
Timo Sirainen <tss@iki.fi>
parents:
1033
diff
changeset
|
20 typedef void io_callback_t(void *context); |
f782b3319553
Removed useless parameters from io_callback_t and timeout_callback_t.
Timo Sirainen <tss@iki.fi>
parents:
1033
diff
changeset
|
21 typedef void timeout_callback_t(void *context); |
0 | 22 |
23 /* Time when the I/O loop started calling handlers. | |
24 Can be used instead of time(NULL). */ | |
25 extern time_t ioloop_time; | |
26 extern struct timeval ioloop_timeval; | |
492
efa46e28a0d7
Fixes to timezone handling which were handling quite badly. added
Timo Sirainen <tss@iki.fi>
parents:
389
diff
changeset
|
27 extern struct timezone ioloop_timezone; |
0 | 28 |
3798
be1bac1dd005
Export current_ioloop globally.
Timo Sirainen <tss@iki.fi>
parents:
3613
diff
changeset
|
29 extern struct ioloop *current_ioloop; |
be1bac1dd005
Export current_ioloop globally.
Timo Sirainen <tss@iki.fi>
parents:
3613
diff
changeset
|
30 |
0 | 31 /* I/O listeners - you can create different handlers for IO_READ and IO_WRITE, |
32 but make sure you don't create multiple handlers of same type, it's not | |
1729
5bf22d6bb65e
Added IO_DIR_NOTIFY and IO_FILE_NOTIFY conditions to io_add(). IO_DIR_NOTIFY
Timo Sirainen <tss@iki.fi>
parents:
1499
diff
changeset
|
33 checked and removing one will stop the other from working as well. |
5bf22d6bb65e
Added IO_DIR_NOTIFY and IO_FILE_NOTIFY conditions to io_add(). IO_DIR_NOTIFY
Timo Sirainen <tss@iki.fi>
parents:
1499
diff
changeset
|
34 |
3534
a9be1824403b
New inotify code and notify API change. Patch by Johannes Berg
Timo Sirainen <tss@iki.fi>
parents:
1729
diff
changeset
|
35 */ |
1729
5bf22d6bb65e
Added IO_DIR_NOTIFY and IO_FILE_NOTIFY conditions to io_add(). IO_DIR_NOTIFY
Timo Sirainen <tss@iki.fi>
parents:
1499
diff
changeset
|
36 struct io *io_add(int fd, enum io_condition condition, |
5bf22d6bb65e
Added IO_DIR_NOTIFY and IO_FILE_NOTIFY conditions to io_add(). IO_DIR_NOTIFY
Timo Sirainen <tss@iki.fi>
parents:
1499
diff
changeset
|
37 io_callback_t *callback, void *context); |
3534
a9be1824403b
New inotify code and notify API change. Patch by Johannes Berg
Timo Sirainen <tss@iki.fi>
parents:
1729
diff
changeset
|
38 struct io *io_add_notify(const char *path, io_callback_t *callback, |
a9be1824403b
New inotify code and notify API change. Patch by Johannes Berg
Timo Sirainen <tss@iki.fi>
parents:
1729
diff
changeset
|
39 void *context); |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
492
diff
changeset
|
40 void io_remove(struct io *io); |
0 | 41 |
42 /* Timeout handlers */ | |
1499
e850252cdc7e
Removed I/O priorities. They were pretty much useless and were just getting
Timo Sirainen <tss@iki.fi>
parents:
1431
diff
changeset
|
43 struct timeout *timeout_add(unsigned int msecs, timeout_callback_t *callback, |
953
411006be3c66
Naming change for function typedefs.
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
44 void *context); |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
492
diff
changeset
|
45 void timeout_remove(struct timeout *timeout); |
0 | 46 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
492
diff
changeset
|
47 void io_loop_run(struct ioloop *ioloop); |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
492
diff
changeset
|
48 void io_loop_stop(struct ioloop *ioloop); /* safe to run in signal handler */ |
0 | 49 |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3798
diff
changeset
|
50 bool io_loop_is_running(struct ioloop *ioloop); |
1033 | 51 |
0 | 52 /* call these if you wish to run the iteration only once */ |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
492
diff
changeset
|
53 void io_loop_set_running(struct ioloop *ioloop); |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
492
diff
changeset
|
54 void io_loop_handler_run(struct ioloop *ioloop); |
0 | 55 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
492
diff
changeset
|
56 struct ioloop *io_loop_create(pool_t pool); |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
492
diff
changeset
|
57 void io_loop_destroy(struct ioloop *ioloop); |
0 | 58 |
59 #endif |