]> git.sesse.net Git - cubemap/blobdiff - acceptor.h
Tweak the MutexLock implementation slightly, so as to confuse Coverity less.
[cubemap] / acceptor.h
index 5cd579da11381f731aa9d5d46dcda3a3f9113301..e0a1bd54811df6e4be0a28de9f5e415d48cc53b5 100644 (file)
@@ -1,26 +1,32 @@
 #ifndef _ACCEPTOR_H
 #define _ACCEPTOR_H
 
-int create_server_socket(int port);
+#include "thread.h"
+
+enum SocketType {
+       TCP_SOCKET,
+       UDP_SOCKET,
+};
+int create_server_socket(int port, SocketType socket_type);
+
+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)