~ubuntu-branches/ubuntu/wily/dovecot/wily

« back to all changes in this revision

Viewing changes to src/lib/ioloop.h

  • Committer: Package Import Robot
  • Author(s): Jaldhar H. Vyas
  • Date: 2013-09-09 00:57:32 UTC
  • mfrom: (1.13.11)
  • mto: (4.8.5 experimental) (1.16.1)
  • mto: This revision was merged to the branch mainline in revision 97.
  • Revision ID: package-import@ubuntu.com-20130909005732-dn1eell8srqbhh0e
Tags: upstream-2.2.5
ImportĀ upstreamĀ versionĀ 2.2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
   the behavior will be undefined. */
48
48
struct io *io_add(int fd, enum io_condition condition,
49
49
                  unsigned int source_linenum,
50
 
                  io_callback_t *callback, void *context);
 
50
                  io_callback_t *callback, void *context) ATTR_NULL(5);
51
51
#define io_add(fd, condition, callback, context) \
52
 
        CONTEXT_CALLBACK(io_add, io_callback_t, \
53
 
                         callback, context, fd, condition, __LINE__)
54
 
enum io_notify_result io_add_notify(const char *path, io_callback_t *callback,
55
 
                                    void *context, struct io **io_r);
56
 
#ifdef CONTEXT_TYPE_SAFETY
57
 
#  define io_add_notify(path, callback, context, io_r) \
58
 
        ({(void)(1 ? 0 : callback(context)); \
59
 
        io_add_notify(path, (io_callback_t *)callback, context, io_r); })
60
 
#else
61
 
#  define io_add_notify(path, callback, context, io_r) \
62
 
        io_add_notify(path, (io_callback_t *)callback, context, io_r)
63
 
#endif
 
52
        io_add(fd, condition, __LINE__ + \
 
53
                CALLBACK_TYPECHECK(callback, void (*)(typeof(context))), \
 
54
                (io_callback_t *)callback, context)
 
55
enum io_notify_result
 
56
io_add_notify(const char *path, io_callback_t *callback,
 
57
              void *context, struct io **io_r) ATTR_NULL(3);
 
58
#define io_add_notify(path, callback, context, io_r) \
 
59
        io_add_notify(path + \
 
60
                CALLBACK_TYPECHECK(callback, void (*)(typeof(context))), \
 
61
                (io_callback_t *)callback, context, io_r)
64
62
 
65
63
/* Remove I/O handler, and set io pointer to NULL. */
66
64
void io_remove(struct io **io);
69
67
void io_remove_closed(struct io **io);
70
68
 
71
69
/* Timeout handlers */
72
 
struct timeout *timeout_add(unsigned int msecs, unsigned int source_linenum,
73
 
                            timeout_callback_t *callback, void *context);
 
70
struct timeout *
 
71
timeout_add(unsigned int msecs, unsigned int source_linenum,
 
72
            timeout_callback_t *callback, void *context) ATTR_NULL(4);
74
73
#define timeout_add(msecs, callback, context) \
75
 
        CONTEXT_CALLBACK(timeout_add, timeout_callback_t, \
76
 
                         callback, context, msecs, __LINE__)
 
74
        timeout_add(msecs, __LINE__ + \
 
75
                CALLBACK_TYPECHECK(callback, void (*)(typeof(context))) + \
 
76
                COMPILE_ERROR_IF_TRUE(__builtin_constant_p(msecs) && \
 
77
                                      (msecs > 0 && msecs < 1000)), \
 
78
                (io_callback_t *)callback, context)
 
79
struct timeout *
 
80
timeout_add_short(unsigned int msecs, unsigned int source_linenum,
 
81
                  timeout_callback_t *callback, void *context) ATTR_NULL(4);
 
82
#define timeout_add_short(msecs, callback, context) \
 
83
        timeout_add_short(msecs, __LINE__ + \
 
84
                CALLBACK_TYPECHECK(callback, void (*)(typeof(context))), \
 
85
                (io_callback_t *)callback, context)
77
86
/* Remove timeout handler, and set timeout pointer to NULL. */
78
87
void timeout_remove(struct timeout **timeout);
79
88
/* Reset timeout so it's next run after now+msecs. */
128
137
struct io *io_loop_move_io(struct io **io);
129
138
/* Like io_loop_move_io(), but for timeouts. */
130
139
struct timeout *io_loop_move_timeout(struct timeout **timeout);
 
140
/* Returns TRUE if any IOs have been added to the ioloop. */
 
141
bool io_loop_have_ios(struct ioloop *ioloop);
 
142
/* Returns TRUE if there is a pending timeout that is going to be run
 
143
   immediately. */
 
144
bool io_loop_have_immediate_timeouts(struct ioloop *ioloop);
131
145
 
132
146
#endif