1 /* IOHandler.c - IOMultiplexer v2
2 * Copyright (C) 2014 Philipp Kreil (pk910)
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #define _IOHandler_internals
18 #include "IOInternal.h"
19 #include "IOHandler.h"
22 #include "IOGarbageCollector.h"
24 #include "IODNSLookup.h"
25 #include "IOSockets.h"
31 #include "compat/utime.h"
33 #define IOHANDLER_STATE_INITIALIZED 0x0001
34 #define IOHANDLER_STATE_RUNNING 0x0002
36 static int iohandler_state = 0;
39 void iohandler_init() {
40 if((iohandler_state & IOHANDLER_STATE_INITIALIZED))
52 iohandler_state |= IOHANDLER_STATE_INITIALIZED;
55 void iohandler_stop() {
56 iohandler_state &= ~IOHANDLER_STATE_RUNNING;
59 static void iohandler_loop() {
60 while(iohandler_state & IOHANDLER_STATE_RUNNING) { // endless loop
64 iosocket_loop(IOHANDLER_LOOP_MAXTIME);
69 void iohandler_run() {
70 iohandler_state |= IOHANDLER_STATE_RUNNING;