connection_manager.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // connection_manager.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef EXPERIMENTAL_HTTP_SERVER_CONNECTION_MANAGER_H
  11. #define EXPERIMENTAL_HTTP_SERVER_CONNECTION_MANAGER_H
  12. #include <set>
  13. #include <boost/noncopyable.hpp>
  14. #include "Experimental/http_server/connection.h"
  15. namespace http_server {
  16. /// Manages open connections so that they may be cleanly stopped when the server
  17. /// needs to shut down.
  18. class connection_manager: private boost::noncopyable
  19. {
  20. public:
  21. /// Add the specified connection to the manager and start it.
  22. void start(connection_ptr c);
  23. /// Stop the specified connection.
  24. void stop(connection_ptr c);
  25. /// Stop all connections.
  26. void stop_all();
  27. private:
  28. /// The managed connections.
  29. std::set<connection_ptr> connections_;
  30. };
  31. } // namespace http_server
  32. #endif // EXPERIMENTAL_HTTP_SERVER_CONNECTION_MANAGER_H