Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/lib/ioloop-internal.h @ 8100:83aef3a6c0a3 HEAD
Added io_remove_closed().
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 21 Aug 2008 07:35:59 +0300 |
parents | 3e506d46655f |
children | 2c111b572eee |
rev | line source |
---|---|
6410
e4eb71ae8e96
Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents:
5330
diff
changeset
|
1 #ifndef IOLOOP_INTERNAL_H |
e4eb71ae8e96
Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents:
5330
diff
changeset
|
2 #define IOLOOP_INTERNAL_H |
0 | 3 |
7098
becdf2eacdce
Use priority queue to implement timeout handling. Added timeout_reset().
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
4 #include "priorityq.h" |
0 | 5 #include "ioloop.h" |
6 | |
4573
8d977716f449
Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
3959
diff
changeset
|
7 #ifndef IOLOOP_INITIAL_FD_COUNT |
8d977716f449
Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
3959
diff
changeset
|
8 # define IOLOOP_INITIAL_FD_COUNT 128 |
8d977716f449
Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
3959
diff
changeset
|
9 #endif |
8d977716f449
Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
3959
diff
changeset
|
10 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
11 struct ioloop { |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
12 struct ioloop *prev; |
0 | 13 |
5248
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
14 struct io_file *io_files; |
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
15 struct io_file *next_io_file; |
7098
becdf2eacdce
Use priority queue to implement timeout handling. Added timeout_reset().
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
16 struct priorityq *timeouts; |
0 | 17 |
3483
84a4f150bd00
data -> context/ctx naming convention replaces
Timo Sirainen <tss@iki.fi>
parents:
3482
diff
changeset
|
18 struct ioloop_handler_context *handler_context; |
3482
465c465c66be
Added inotify patch by Johannes Berg and did some restructuring to
Timo Sirainen <tss@iki.fi>
parents:
2496
diff
changeset
|
19 struct ioloop_notify_handler_context *notify_handler_context; |
0 | 20 |
21 unsigned int running:1; | |
22 }; | |
23 | |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
24 struct io { |
1752 | 25 enum io_condition condition; |
0 | 26 |
1036
f782b3319553
Removed useless parameters from io_callback_t and timeout_callback_t.
Timo Sirainen <tss@iki.fi>
parents:
953
diff
changeset
|
27 io_callback_t *callback; |
10
82b7de533f98
s/user_data/context/ and some s/Data/Context/
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
28 void *context; |
0 | 29 }; |
30 | |
5248
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
31 struct io_file { |
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
32 struct io io; |
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
33 |
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
34 /* use a doubly linked list so that io_remove() is quick */ |
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
35 struct io_file *prev, *next; |
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
36 |
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
37 int refcount; |
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
38 int fd; |
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
39 }; |
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
40 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
41 struct timeout { |
7098
becdf2eacdce
Use priority queue to implement timeout handling. Added timeout_reset().
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
42 struct priorityq_item item; |
0 | 43 |
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 unsigned int msecs; |
7098
becdf2eacdce
Use priority queue to implement timeout handling. Added timeout_reset().
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
45 struct timeval next_run; |
0 | 46 |
1036
f782b3319553
Removed useless parameters from io_callback_t and timeout_callback_t.
Timo Sirainen <tss@iki.fi>
parents:
953
diff
changeset
|
47 timeout_callback_t *callback; |
10
82b7de533f98
s/user_data/context/ and some s/Data/Context/
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
48 void *context; |
0 | 49 }; |
50 | |
7152
3e506d46655f
timeout_get_wait_time() may have returned negative seconds in timeval. Also
Timo Sirainen <tss@iki.fi>
parents:
7098
diff
changeset
|
51 int io_loop_get_wait_time(struct ioloop *ioloop, struct timeval *tv_r, |
0 | 52 struct timeval *tv_now); |
7098
becdf2eacdce
Use priority queue to implement timeout handling. Added timeout_reset().
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
53 void io_loop_handle_timeouts(struct ioloop *ioloop); |
0 | 54 |
55 /* I/O handler calls */ | |
5248
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
56 void io_loop_handle_add(struct ioloop *ioloop, struct io_file *io); |
8100 | 57 void io_loop_handle_remove(struct ioloop *ioloop, struct io_file *io, |
58 bool closed); | |
0 | 59 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
60 void io_loop_handler_init(struct ioloop *ioloop); |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
61 void io_loop_handler_deinit(struct ioloop *ioloop); |
0 | 62 |
5248
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
63 void io_loop_notify_remove(struct ioloop *ioloop, struct io *io); |
3482
465c465c66be
Added inotify patch by Johannes Berg and did some restructuring to
Timo Sirainen <tss@iki.fi>
parents:
2496
diff
changeset
|
64 void io_loop_notify_handler_deinit(struct ioloop *ioloop); |
465c465c66be
Added inotify patch by Johannes Berg and did some restructuring to
Timo Sirainen <tss@iki.fi>
parents:
2496
diff
changeset
|
65 |
0 | 66 #endif |