46
46
Don't try to add multiple handlers for the same type. It's not checked and
47
47
the behavior will be undefined. */
48
48
struct io *io_add(int fd, enum io_condition condition,
49
unsigned int source_linenum,
49
50
io_callback_t *callback, void *context);
50
51
#define io_add(fd, condition, callback, context) \
51
52
CONTEXT_CALLBACK(io_add, io_callback_t, \
52
callback, context, fd, condition)
53
callback, context, fd, condition, __LINE__)
53
54
enum io_notify_result io_add_notify(const char *path, io_callback_t *callback,
54
55
void *context, struct io **io_r);
55
56
#ifdef CONTEXT_TYPE_SAFETY
68
69
void io_remove_closed(struct io **io);
70
71
/* Timeout handlers */
71
struct timeout *timeout_add(unsigned int msecs, timeout_callback_t *callback,
72
struct timeout *timeout_add(unsigned int msecs, unsigned int source_linenum,
73
timeout_callback_t *callback, void *context);
73
74
#define timeout_add(msecs, callback, context) \
74
75
CONTEXT_CALLBACK(timeout_add, timeout_callback_t, \
75
callback, context, msecs)
76
callback, context, msecs, __LINE__)
76
77
/* Remove timeout handler, and set timeout pointer to NULL. */
77
78
void timeout_remove(struct timeout **timeout);
78
79
/* Reset timeout so it's next run after now+msecs. */
103
104
/* Change the current_ioloop. */
104
105
void io_loop_set_current(struct ioloop *ioloop);
106
/* This log is used for all further I/O and timeout callbacks that are added
107
until returning to ioloop. */
108
struct ioloop_log *io_loop_log_new(struct ioloop *ioloop);
109
void io_loop_log_ref(struct ioloop_log *log);
110
void io_loop_log_unref(struct ioloop_log **log);
111
/* Set the log's prefix. Note that this doesn't immediately call
112
i_set_failure_prefix(). */
113
void io_loop_log_set_prefix(struct ioloop_log *log, const char *prefix);
114
/* Set the default log prefix to use outside callbacks. */
115
void io_loop_set_default_log_prefix(struct ioloop *ioloop, const char *prefix);
107
/* This context is used for all further I/O and timeout callbacks that are
108
added until returning to ioloop. When a callback is called, this context is
110
struct ioloop_context *io_loop_context_new(struct ioloop *ioloop);
111
void io_loop_context_ref(struct ioloop_context *ctx);
112
void io_loop_context_unref(struct ioloop_context **ctx);
113
/* Call the activate callback when this context is activated (I/O callback is
114
about to be called), and the deactivate callback when the context is
115
deactivated (I/O callback has returned). You can add multiple callbacks. */
116
void io_loop_context_add_callbacks(struct ioloop_context *ctx,
117
io_callback_t *activate,
118
io_callback_t *deactivate, void *context);
119
/* Remove callbacks with the given callbacks and context. */
120
void io_loop_context_remove_callbacks(struct ioloop_context *ctx,
121
io_callback_t *activate,
122
io_callback_t *deactivate, void *context);
123
/* Returns the current context set to ioloop. */
124
struct ioloop_context *io_loop_get_current_context(struct ioloop *ioloop);
126
/* Move the given I/O into the current I/O loop if it's not already
127
there. New I/O is returned, while the old one is freed. */
128
struct io *io_loop_move_io(struct io **io);
129
/* Like io_loop_move_io(), but for timeouts. */
130
struct timeout *io_loop_move_timeout(struct timeout **timeout);