Files
libucore/src/iomux_impl.h
T
2015-05-11 23:36:23 +02:00

55 lines
1.7 KiB
C

#ifndef IO_MUX_IMPL_H_
#define IO_MUX_IMPL_H_
#include "ucore/iomux.h"
#include "ucore/timers.h"
/** struct for IOMux implementations */
struct IOMuxOps {
/** Run one iteration of the mux.
* The mux implementation must honor the timeout, if given.
* The mux implementation must call iomux_timers_run after the
* polling has occured (or if it's polling times out)
*
* @param mux The IOMux instance
* @param timeout absolute time of a timeout - after which timers should run.
* If timeout is NULL, no timeout should be set on the poll.
*/
int (*run_impl)(struct IOMux *mux, struct timeval *timeout);
/* Deallocate the instance specific part of the IOMux */
void (*delete_impl)(struct IOMux *mux);
/** Register an IOMuxFD for events*/
int (*register_fd_impl)(struct IOMux *mux, struct IOMuxFD *fd);
/** Unregister an IOMuxFD */
int (*unregister_fd_impl)(struct IOMux *mux, struct IOMuxFD *fd);
/** Update an IOMuxFD (due to its events ('what') has changed*/
int (*update_events_impl)(struct IOMux *mux, struct IOMuxFD *fd);
};
struct IOMux {
/* TImer instance - must be the 1. member*/
struct UCTimers timers;
/**
* Clock used for driving timers, and
* providing timeouts for the mux
*/
struct UCoreClock *uclock;
struct IOMuxOps ops;
/* Used by mux implementations to hold their own data/instance */
void *instance;
};
//TODO - have iomux_xx_init embed struct IOMux and get rid of IOMux.instance
//for better cache friendiness
int iomux_select_init(struct IOMux *mux);
int iomux_epoll_init(struct IOMux *mux);
int iomux_timers_run(struct IOMux *mux);
#endif