]> git.sesse.net Git - cubemap/blobdiff - acceptor.h
Wrap the acceptor into the same thread logic as everything else.
[cubemap] / acceptor.h
index f173e5b647e68d9c4d8cad2ac64e99b7c4523dd0..5cd579da11381f731aa9d5d46dcda3a3f9113301 100644 (file)
@@ -5,6 +5,22 @@ int create_server_socket(int port);
 
 // A thread that accepts new connections on a given socket,
 // and hands them off to the server pool.
-void *acceptor_thread_run(void *arg);
+class AcceptorThread {
+public:
+       AcceptorThread(int server_sock);
+       void run();
+       void stop();
+
+private:
+       // Recovers the this pointer, and hands over control to do_work().
+       static void *do_work_thunk(void *arg);
+
+       void do_work();
+
+       int server_sock;
+
+       pthread_t worker_thread;
+       volatile bool should_stop;
+};
 
 #endif  // !defined(_ACCEPTOR_H)