+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;
+ clock_gettime(EVENT_CLOCK, &loop->now);
+}
+
+void event_loop_exit(event_loop_t *loop) {
+ assert(!loop->ios.count);
+ assert(!loop->timeouts.count);
+ assert(!loop->signals.count);
+
+ 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);
+ }