Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/lib/ioloop.h @ 4150:49e024519e22 HEAD
IO_ERROR and IO_NOTIFY had conflicting values.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 09 Apr 2006 17:48:34 +0300 |
parents | fcd4c3281559 |
children | 40b353def38c |
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 */ |
4150
49e024519e22
IO_ERROR and IO_NOTIFY had conflicting values.
Timo Sirainen <tss@iki.fi>
parents:
4039
diff
changeset
|
17 IO_NOTIFY = 0x08 |
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); |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
40 /* Remove I/O handler, and set io pointer to NULL. */ |
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
41 void io_remove(struct io **io); |
0 | 42 |
43 /* 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
|
44 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
|
45 void *context); |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
46 /* Remove timeout handler, and set timeout pointer to NULL. */ |
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
47 void timeout_remove(struct timeout **timeout); |
0 | 48 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
492
diff
changeset
|
49 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
|
50 void io_loop_stop(struct ioloop *ioloop); /* safe to run in signal handler */ |
0 | 51 |
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
|
52 bool io_loop_is_running(struct ioloop *ioloop); |
1033 | 53 |
0 | 54 /* 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
|
55 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
|
56 void io_loop_handler_run(struct ioloop *ioloop); |
0 | 57 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
492
diff
changeset
|
58 struct ioloop *io_loop_create(pool_t pool); |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
59 /* Destroy I/O loop and set ioloop pointer to NULL. */ |
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
60 void io_loop_destroy(struct ioloop **ioloop); |
0 | 61 |
62 #endif |