asiolink.h 3.5 KB

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