connect_pipe.hpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //
  2. // connect_pipe.hpp
  3. // ~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2023 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 ASIO_CONNECT_PIPE_HPP
  11. #define 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 "asio/detail/config.hpp"
  16. #if defined(ASIO_HAS_PIPE) \
  17. || defined(GENERATING_DOCUMENTATION)
  18. #include "asio/basic_readable_pipe.hpp"
  19. #include "asio/basic_writable_pipe.hpp"
  20. #include "asio/error.hpp"
  21. #include "asio/detail/push_options.hpp"
  22. namespace asio {
  23. namespace detail {
  24. #if defined(ASIO_HAS_IOCP)
  25. typedef HANDLE native_pipe_handle;
  26. #else // defined(ASIO_HAS_IOCP)
  27. typedef int native_pipe_handle;
  28. #endif // defined(ASIO_HAS_IOCP)
  29. ASIO_DECL void create_pipe(native_pipe_handle p[2],
  30. asio::error_code& ec);
  31. ASIO_DECL void close_pipe(native_pipe_handle p);
  32. } // namespace detail
  33. /// Connect two pipe ends using an anonymous pipe.
  34. /**
  35. * @param read_end The read end of the pipe.
  36. *
  37. * @param write_end The write end of the pipe.
  38. *
  39. * @throws asio::system_error Thrown on failure.
  40. */
  41. template <typename Executor1, typename Executor2>
  42. void connect_pipe(basic_readable_pipe<Executor1>& read_end,
  43. basic_writable_pipe<Executor2>& write_end);
  44. /// Connect two pipe ends using an anonymous pipe.
  45. /**
  46. * @param read_end The read end of the pipe.
  47. *
  48. * @param write_end The write end of the pipe.
  49. *
  50. * @throws asio::system_error Thrown on failure.
  51. *
  52. * @param ec Set to indicate what error occurred, if any.
  53. */
  54. template <typename Executor1, typename Executor2>
  55. ASIO_SYNC_OP_VOID connect_pipe(basic_readable_pipe<Executor1>& read_end,
  56. basic_writable_pipe<Executor2>& write_end, asio::error_code& ec);
  57. } // namespace asio
  58. #include "asio/detail/pop_options.hpp"
  59. #include "asio/impl/connect_pipe.hpp"
  60. #if defined(ASIO_HEADER_ONLY)
  61. # include "asio/impl/connect_pipe.ipp"
  62. #endif // defined(ASIO_HEADER_ONLY)
  63. #endif // defined(ASIO_HAS_PIPE)
  64. // || defined(GENERATING_DOCUMENTATION)
  65. #endif // ASIO_CONNECT_PIPE_HPP