]> git.sesse.net Git - cubemap/blob - acceptor.h
5cd579da11381f731aa9d5d46dcda3a3f9113301
[cubemap] / acceptor.h
1 #ifndef _ACCEPTOR_H
2 #define _ACCEPTOR_H
3
4 int create_server_socket(int port);
5
6 // A thread that accepts new connections on a given socket,
7 // and hands them off to the server pool.
8 class AcceptorThread {
9 public:
10         AcceptorThread(int server_sock);
11         void run();
12         void stop();
13
14 private:
15         // Recovers the this pointer, and hands over control to do_work().
16         static void *do_work_thunk(void *arg);
17
18         void do_work();
19
20         int server_sock;
21
22         pthread_t worker_thread;
23         volatile bool should_stop;
24 };
25
26 #endif  // !defined(_ACCEPTOR_H)