Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. void startServer(int port)
  2. {
  3. Server server(port);
  4. server.run();
  5. }
  6.  
  7. void handler(int)
  8. {
  9. // What to do here to make sure the `Server` object
  10. // owned by the tread is properly destroyed?
  11. // Remember: when this code executes, the thread is probably
  12. // blocked by a call to accept().
  13. }
  14.  
  15. int main(int argc, char **argv)
  16. {
  17. signal(SIGINT, handler);
  18. std::thread serverThread(std::bind(startServer,
  19. std::stoi(argv[1])));
  20.  
  21. while (true)
  22. {
  23. // do work in main thread
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement