connection_manager.hpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // connection_manager.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2019 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 HTTP_CONNECTION_MANAGER_HPP
  11. #define HTTP_CONNECTION_MANAGER_HPP
  12. #include <set>
  13. #include "connection.hpp"
  14. namespace http {
  15. namespace server {
  16. /// Manages open connections so that they may be cleanly stopped when the server
  17. /// needs to shut down.
  18. class connection_manager
  19. {
  20. public:
  21. connection_manager(const connection_manager&) = delete;
  22. connection_manager& operator=(const connection_manager&) = delete;
  23. /// Construct a connection manager.
  24. connection_manager();
  25. /// Add the specified connection to the manager and start it.
  26. void start(connection_ptr c);
  27. /// Stop the specified connection.
  28. void stop(connection_ptr c);
  29. /// Stop all connections.
  30. void stop_all();
  31. private:
  32. /// The managed connections.
  33. std::set<connection_ptr> connections_;
  34. };
  35. } // namespace server
  36. } // namespace http
  37. #endif // HTTP_CONNECTION_MANAGER_HPP