view src/lib/ioloop-internal.h @ 3749:194295062e5e HEAD

Added kqueue support. Patch by Vaclav Haisman.
author Timo Sirainen <tss@iki.fi>
date Wed, 14 Dec 2005 20:51:52 +0200
parents a9be1824403b
children ef5595d6ddec
line wrap: on
line source

#ifndef __IOLOOP_INTERNAL_H
#define __IOLOOP_INTERNAL_H

#include "ioloop.h"

struct ioloop {
        struct ioloop *prev;

	pool_t pool;

	struct io *ios;
	struct io *notifys;
	struct io *next_io;
	struct timeout *timeouts; /* sorted by next_run */

        struct ioloop_handler_context *handler_context;
        struct ioloop_notify_handler_context *notify_handler_context;

	unsigned int running:1;
};

struct io {
	struct io *prev, *next;

	int fd;
	enum io_condition condition;

	io_callback_t *callback;
        void *context;

        int notify_context;
};

struct timeout {
	struct timeout *next;

	struct timeval next_run;
        unsigned int msecs;

	unsigned int run_now:1;
	unsigned int destroyed:1;

	timeout_callback_t *callback;
        void *context;
};

int io_loop_get_wait_time(struct timeout *timeout, struct timeval *tv,
			  struct timeval *tv_now);
void io_loop_handle_timeouts(struct ioloop *ioloop);

/* call only when timeout->destroyed is TRUE */
void timeout_destroy(struct ioloop *ioloop, struct timeout **timeout_p);

/* I/O handler calls */
void io_loop_handle_add(struct ioloop *ioloop, struct io *io);
void io_loop_handle_remove(struct ioloop *ioloop, struct io *io);

void io_loop_handler_init(struct ioloop *ioloop);
void io_loop_handler_deinit(struct ioloop *ioloop);

void io_loop_notify_handler_init(struct ioloop *ioloop);
void io_loop_notify_handler_deinit(struct ioloop *ioloop);

struct io *io_loop_notify_add(struct ioloop *ioloop, const char *path,
			      io_callback_t *callback, void *context);
void io_loop_notify_remove(struct ioloop *ioloop, struct io *io);

#endif