]> git.sesse.net Git - cubemap/blobdiff - acceptor.cpp
Factor all the common thread starting/stopping into a common Thread class.
[cubemap] / acceptor.cpp
index 0b8de507af4d0b5576cb2f9aa309ba6e68519a62..7620b7991104d98d19364559b46d6778d4c7919e 100644 (file)
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <signal.h>
 #include <errno.h>
 #include <arpa/inet.h>
 #include <sys/ioctl.h>
@@ -59,10 +60,14 @@ int create_server_socket(int port)
 
        return server_sock;
 }
+       
+AcceptorThread::AcceptorThread(int server_sock)
+       : server_sock(server_sock)
+{
+}
 
-void *acceptor_thread_run(void *arg)
+void AcceptorThread::do_work()
 {
-       int server_sock = int(intptr_t(arg));
        while (!hupped) {
                // Since we are non-blocking, we need to wait for the right state first.
                // Wait up to 50 ms, then check hupped.
@@ -104,5 +109,4 @@ void *acceptor_thread_run(void *arg)
                // Pick a server, round-robin, and hand over the socket to it.
                servers->add_client(sock);
        }
-       return NULL;
 }