Imported Upstream version 1.64.0
[platform/upstream/boost.git] / boost / process / detail / windows / on_exit.hpp
1 // Copyright (c) 2016 Klemens D. Morgenstern\r
2 //\r
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying\r
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\r
5
6 #ifndef BOOST_PROCESS_WINDOWS_ON_EXIT_HPP_\r
7 #define BOOST_PROCESS_WINDOWS_ON_EXIT_HPP_\r
8
9 #include <boost/process/detail/config.hpp>\r
10 #include <boost/process/detail/handler_base.hpp>\r
11 #include <boost/process/detail/windows/async_handler.hpp>\r
12 #include <boost/detail/winapi/process.hpp>\r
13 #include <system_error>\r
14 #include <functional>\r
15
16 namespace boost { namespace process { namespace detail { namespace windows {\r
17
18 struct on_exit_ : boost::process::detail::windows::async_handler\r
19 {\r
20     std::function<void(int, const std::error_code&)> handler;\r
21     on_exit_(const std::function<void(int, const std::error_code&)> & handler) : handler(handler)\r
22     {\r
23
24     }\r
25
26     template<typename Executor>\r
27     std::function<void(int, const std::error_code&)> on_exit_handler(Executor&)\r
28     {\r
29         auto handler = this->handler;\r
30         return [handler](int exit_code, const std::error_code & ec)\r
31                {\r
32                     handler(static_cast<int>(exit_code), ec);\r
33                };\r
34
35     }\r
36 };\r
37
38
39 }}}}\r
40 #endif /* INCLUDE_BOOST_PROCESS_WINDOWS_ON_EXIT_HPP_ */\r