connect_pipe.hpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // connect_pipe.hpp
  3. // ~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef BOOST_ASIO_CONNECT_PIPE_HPP
  11. #define BOOST_ASIO_CONNECT_PIPE_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/config.hpp>
  16. #if defined(BOOST_ASIO_HAS_PIPE) \
  17. || defined(GENERATING_DOCUMENTATION)
  18. #include <boost/asio/basic_readable_pipe.hpp>
  19. #include <boost/asio/basic_writable_pipe.hpp>
  20. #include <boost/asio/error.hpp>
  21. #include <boost/asio/detail/push_options.hpp>
  22. namespace boost {
  23. namespace asio {
  24. namespace detail {
  25. #if defined(BOOST_ASIO_HAS_IOCP)
  26. typedef HANDLE native_pipe_handle;
  27. #else // defined(BOOST_ASIO_HAS_IOCP)
  28. typedef int native_pipe_handle;
  29. #endif // defined(BOOST_ASIO_HAS_IOCP)
  30. BOOST_ASIO_DECL void create_pipe(native_pipe_handle p[2],
  31. boost::system::error_code& ec);
  32. BOOST_ASIO_DECL void close_pipe(native_pipe_handle p);
  33. } // namespace detail
  34. /// Connect two pipe ends using an anonymous pipe.
  35. /**
  36. * @param read_end The read end of the pipe.
  37. *
  38. * @param write_end The write end of the pipe.
  39. *
  40. * @throws boost::system::system_error Thrown on failure.
  41. */
  42. template <typename Executor1, typename Executor2>
  43. void connect_pipe(basic_readable_pipe<Executor1>& read_end,
  44. basic_writable_pipe<Executor2>& write_end);
  45. /// Connect two pipe ends using an anonymous pipe.
  46. /**
  47. * @param read_end The read end of the pipe.
  48. *
  49. * @param write_end The write end of the pipe.
  50. *
  51. * @throws boost::system::system_error Thrown on failure.
  52. *
  53. * @param ec Set to indicate what error occurred, if any.
  54. */
  55. template <typename Executor1, typename Executor2>
  56. BOOST_ASIO_SYNC_OP_VOID connect_pipe(basic_readable_pipe<Executor1>& read_end,
  57. basic_writable_pipe<Executor2>& write_end, boost::system::error_code& ec);
  58. } // namespace asio
  59. } // namespace boost
  60. #include <boost/asio/detail/pop_options.hpp>
  61. #include <boost/asio/impl/connect_pipe.hpp>
  62. #if defined(BOOST_ASIO_HEADER_ONLY)
  63. # include <boost/asio/impl/connect_pipe.ipp>
  64. #endif // defined(BOOST_ASIO_HEADER_ONLY)
  65. #endif // defined(BOOST_ASIO_HAS_PIPE)
  66. // || defined(GENERATING_DOCUMENTATION)
  67. #endif // BOOST_ASIO_CONNECT_PIPE_HPP