asiolink.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // Copyright (C) 2010 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_H
  15. #define __ASIOLINK_H 1
  16. // IMPORTANT NOTE: only very few ASIO headers files can be included in
  17. // this file. In particular, asio.hpp should never be included here.
  18. // See the description of the namespace below.
  19. #include <asiolink/io_service.h>
  20. #include <asiolink/dns_service.h>
  21. #include <asiolink/dns_server.h>
  22. #include <asiolink/dns_lookup.h>
  23. #include <asiolink/dns_answer.h>
  24. #include <asiolink/simple_callback.h>
  25. #include <asiolink/recursive_query.h>
  26. #include <asiolink/interval_timer.h>
  27. #include <asiolink/io_address.h>
  28. #include <asiolink/io_endpoint.h>
  29. #include <asiolink/io_message.h>
  30. #include <asiolink/io_socket.h>
  31. #include <asiolink/io_error.h>
  32. /// \namespace asiolink
  33. /// \brief A wrapper interface for the ASIO library.
  34. ///
  35. /// The \c asiolink namespace is used to define a set of wrapper interfaces
  36. /// for the ASIO library.
  37. ///
  38. /// BIND 10 uses the non-Boost version of ASIO because it's header-only,
  39. /// i.e., does not require a separate library object to be linked, and thus
  40. /// lowers the bar for introduction.
  41. ///
  42. /// But the advantage comes with its own costs: since the header-only version
  43. /// includes more definitions in public header files, it tends to trigger
  44. /// more compiler warnings for our own sources, and, depending on the
  45. /// compiler options, may make the build fail.
  46. ///
  47. /// We also found it may be tricky to use ASIO and standard C++ libraries
  48. /// in a single translation unit, i.e., a .cc file: depending on the order
  49. /// of including header files, ASIO may or may not work on some platforms.
  50. ///
  51. /// This wrapper interface is intended to centralize these
  52. /// problematic issues in a single sub module. Other BIND 10 modules should
  53. /// simply include \c asiolink.h and use the wrapper API instead of
  54. /// including ASIO header files and using ASIO-specific classes directly.
  55. ///
  56. /// This wrapper may be used for other IO libraries if and when we want to
  57. /// switch, but generality for that purpose is not the primary goal of
  58. /// this module. The resulting interfaces are thus straightforward mapping
  59. /// to the ASIO counterparts.
  60. ///
  61. /// Notes to developers:
  62. /// Currently the wrapper interface is fairly specific to use by a
  63. /// DNS server, i.e., b10-auth or b10-resolver. But the plan is to
  64. /// generalize it and have other modules use it as well.
  65. ///
  66. /// One obvious drawback of this approach is performance overhead
  67. /// due to the additional layer. We should eventually evaluate the cost
  68. /// of the wrapper abstraction in benchmark tests. Another drawback is
  69. /// that the wrapper interfaces don't provide all features of ASIO
  70. /// (at least for the moment). We should also re-evaluate the
  71. /// maintenance overhead of providing necessary wrappers as we develop
  72. /// more.
  73. ///
  74. /// On the other hand, we may be able to exploit the wrapper approach to
  75. /// simplify the interfaces (by limiting the usage) and unify performance
  76. /// optimization points.
  77. ///
  78. /// As for optimization, we may want to provide a custom allocator for
  79. /// the placeholder of callback handlers:
  80. /// http://think-async.com/Asio/asio-1.3.1/doc/asio/reference/asio_handler_allocate.html
  81. #endif // __ASIOLINK_H