io_service.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 asiolink {
  20. struct IOServiceImpl;
  21. /// \brief The \c IOService class is a wrapper for the ASIO \c io_service
  22. /// class.
  23. ///
  24. class IOService {
  25. ///
  26. /// \name Constructors and Destructor
  27. ///
  28. /// Note: The copy constructor and the assignment operator are
  29. /// intentionally defined as private, making this class non-copyable.
  30. //@{
  31. private:
  32. IOService(const IOService& source);
  33. IOService& operator=(const IOService& source);
  34. public:
  35. /// \brief The constructor
  36. IOService();
  37. /// \brief The destructor.
  38. ~IOService();
  39. //@}
  40. /// \brief Start the underlying event loop.
  41. ///
  42. /// This method does not return control to the caller until
  43. /// the \c stop() method is called via some handler.
  44. void run();
  45. /// \brief Run the underlying event loop for a single event.
  46. ///
  47. /// This method return control to the caller as soon as the
  48. /// first handler has completed. (If no handlers are ready when
  49. /// it is run, it will block until one is.)
  50. void run_one();
  51. /// \brief Stop the underlying event loop.
  52. ///
  53. /// This will return the control to the caller of the \c run() method.
  54. void stop();
  55. /// \brief Return the native \c io_service object used in this wrapper.
  56. ///
  57. /// This is a short term work around to support other BIND 10 modules
  58. /// that share the same \c io_service with the authoritative server.
  59. /// It will eventually be removed once the wrapper interface is
  60. /// generalized.
  61. asio::io_service& get_io_service();
  62. private:
  63. IOServiceImpl* io_impl_;
  64. };
  65. } // namespace asiolink
  66. #endif // __ASIOLINK_IO_SERVICE_H