asiolink.h 3.8 KB

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