+ return true;
+}
+
+void event_flush_output(event_loop_t *loop) {
+ for splay_each(io_t, io, &loop->ios)
+ if(FD_ISSET(io->fd, &loop->writefds)) {
+ io->cb(loop, io->data, IO_WRITE);
+ }
+}
+
+void event_loop_start(event_loop_t *loop) {
+ loop->running = true;
+}
+
+void event_loop_stop(event_loop_t *loop) {
+ loop->running = false;
+}
+
+void event_loop_init(event_loop_t *loop) {
+ loop->ios.compare = (splay_compare_t)io_compare;
+ loop->timeouts.compare = (splay_compare_t)timeout_compare;
+ loop->signals.compare = (splay_compare_t)signal_compare;
+ loop->pipefd[0] = -1;
+ loop->pipefd[1] = -1;
+ gettimeofday(&loop->now, NULL);
+}
+
+void event_loop_exit(event_loop_t *loop) {
+ for splay_each(io_t, io, &loop->ios) {
+ splay_unlink_node(&loop->ios, node);
+ }
+
+ for splay_each(timeout_t, timeout, &loop->timeouts) {
+ splay_unlink_node(&loop->timeouts, node);
+ }
+
+ for splay_each(signal_t, signal, &loop->signals) {
+ splay_unlink_node(&loop->signals, node);
+ }