]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/process/detail/windows/pipe_in.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / process / detail / windows / pipe_in.hpp
1 // Copyright (c) 2006, 2007 Julio M. Merino Vidal
2 // Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
3 // Copyright (c) 2009 Boris Schaeling
4 // Copyright (c) 2010 Felipe Tanus, Boris Schaeling
5 // Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
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_PROCESS_WINDOWS_INITIALIZERS_PIPE_IN_HPP
11 #define BOOST_PROCESS_WINDOWS_INITIALIZERS_PIPE_IN_HPP
12
13 #include <boost/winapi/process.hpp>
14 #include <boost/winapi/handles.hpp>
15 #include <boost/process/detail/handler_base.hpp>
16
17 namespace boost { namespace process { namespace detail { namespace windows {
18
19 struct pipe_in : public ::boost::process::detail::handler_base
20 {
21 ::boost::winapi::HANDLE_ handle;
22
23 pipe_in(::boost::winapi::HANDLE_ handle) : handle(handle) {}
24
25 template<typename T> //async_pipe
26 pipe_in(T & p) : handle(p.native_source())
27 {
28 p.assign_source(::boost::winapi::INVALID_HANDLE_VALUE_);
29 }
30
31 template <class WindowsExecutor>
32 void on_setup(WindowsExecutor &e) const
33 {
34 boost::winapi::SetHandleInformation(handle,
35 boost::winapi::HANDLE_FLAG_INHERIT_,
36 boost::winapi::HANDLE_FLAG_INHERIT_);
37
38 e.startup_info.hStdInput = handle;
39 e.startup_info.dwFlags |= boost::winapi::STARTF_USESTDHANDLES_;
40 e.inherit_handles = true;
41 }
42 template<typename WindowsExecutor>
43 void on_error(WindowsExecutor &, const std::error_code &) const
44 {
45 ::boost::winapi::CloseHandle(handle);
46 }
47
48 template<typename WindowsExecutor>
49 void on_success(WindowsExecutor &) const
50 {
51 ::boost::winapi::CloseHandle(handle);
52 }
53 };
54
55 class async_pipe;
56
57 struct async_pipe_in : public pipe_in
58 {
59 async_pipe &pipe;
60
61 template<typename AsyncPipe>
62 async_pipe_in(AsyncPipe & p) : pipe_in(p.native_source()), pipe(p)
63 {
64 }
65
66 template<typename Pipe, typename Executor>
67 static void close(Pipe & pipe, Executor &)
68 {
69 boost::system::error_code ec;
70 std::move(pipe).source().close(ec);
71 }
72
73 template<typename Executor>
74 void on_error(Executor & exec, const std::error_code &)
75 {
76 close(pipe, exec);
77 }
78
79 template<typename Executor>
80 void on_success(Executor &exec)
81 {
82 close(pipe, exec);
83 }
84 };
85
86
87 }}}}
88
89 #endif