io_service.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #ifndef __ASIOLINK_IO_SERVICE_H
  15. #define __ASIOLINK_IO_SERVICE_H 1
  16. namespace asio {
  17. class io_service;
  18. }
  19. namespace isc {
  20. namespace asiolink {
  21. class IOServiceImpl;
  22. /// \brief The \c IOService class is a wrapper for the ASIO \c io_service
  23. /// class.
  24. ///
  25. class IOService {
  26. ///
  27. /// \name Constructors and Destructor
  28. ///
  29. /// Note: The copy constructor and the assignment operator are
  30. /// intentionally defined as private, making this class non-copyable.
  31. //@{
  32. private:
  33. IOService(const IOService& source);
  34. IOService& operator=(const IOService& source);
  35. public:
  36. /// \brief The constructor
  37. IOService();
  38. /// \brief The destructor.
  39. ~IOService();
  40. //@}
  41. /// \brief Start the underlying event loop.
  42. ///
  43. /// This method does not return control to the caller until
  44. /// the \c stop() method is called via some handler.
  45. void run();
  46. /// \brief Run the underlying event loop for a single event.
  47. ///
  48. /// This method return control to the caller as soon as the
  49. /// first handler has completed. (If no handlers are ready when
  50. /// it is run, it will block until one is.)
  51. void run_one();
  52. /// \brief Stop the underlying event loop.
  53. ///
  54. /// This will return the control to the caller of the \c run() method.
  55. void stop();
  56. /// \brief Return the native \c io_service object used in this wrapper.
  57. ///
  58. /// This is a short term work around to support other BIND 10 modules
  59. /// that share the same \c io_service with the authoritative server.
  60. /// It will eventually be removed once the wrapper interface is
  61. /// generalized.
  62. asio::io_service& get_io_service();
  63. private:
  64. IOServiceImpl* io_impl_;
  65. };
  66. } // namespace asiolink
  67. } // namespace isc
  68. #endif // __ASIOLINK_IO_SERVICE_H