X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=acceptor.h;h=caa46474ce48d83185244cc2e977c155ce882e1b;hb=d60b2c17baf9b71e4a70a499fa1d34753821c822;hp=5cd579da11381f731aa9d5d46dcda3a3f9113301;hpb=156897c8a6c7b86cb244d74911528de5c28f2134;p=cubemap diff --git a/acceptor.h b/acceptor.h index 5cd579d..caa4647 100644 --- a/acceptor.h +++ b/acceptor.h @@ -1,26 +1,28 @@ #ifndef _ACCEPTOR_H #define _ACCEPTOR_H +#include "thread.h" + int create_server_socket(int port); +class AcceptorProto; + // A thread that accepts new connections on a given socket, // and hands them off to the server pool. -class AcceptorThread { +class Acceptor : public Thread { public: - AcceptorThread(int server_sock); - void run(); - void stop(); + Acceptor(int server_sock, int port); -private: - // Recovers the this pointer, and hands over control to do_work(). - static void *do_work_thunk(void *arg); + // Serialization/deserialization. + Acceptor(const AcceptorProto &serialized); + AcceptorProto serialize() const; - void do_work(); + void close_socket(); - int server_sock; +private: + virtual void do_work(); - pthread_t worker_thread; - volatile bool should_stop; + int server_sock, port; }; #endif // !defined(_ACCEPTOR_H)