Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void startServer(int port)
- {
- Server server(port);
- server.run();
- }
- void handler(int)
- {
- // What to do here to make sure the `Server` object
- // owned by the tread is properly destroyed?
- // Remember: when this code executes, the thread is probably
- // blocked by a call to accept().
- }
- int main(int argc, char **argv)
- {
- signal(SIGINT, handler);
- std::thread serverThread(std::bind(startServer,
- std::stoi(argv[1])));
- while (true)
- {
- // do work in main thread
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement