Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:06

0001 // Copyright (c) 2016 Klemens D. Morgenstern
0002 //
0003 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0004 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 #ifndef BOOST_PROCESS_POSIX_ON_EXIT_HPP_
0007 #define BOOST_PROCESS_POSIX_ON_EXIT_HPP_
0008 
0009 #include <boost/asio/execution.hpp>
0010 #include <boost/process/async.hpp>
0011 #include <boost/process/detail/config.hpp>
0012 #include <boost/process/detail/handler_base.hpp>
0013 #include <boost/process/detail/posix/async_handler.hpp>
0014 #include <system_error>
0015 #include <functional>
0016 
0017 namespace boost { namespace process { namespace detail {
0018 
0019 template<typename Tuple>
0020 inline asio::io_context& get_io_context(const Tuple & tup);
0021 
0022 namespace posix {
0023 
0024 struct on_exit_ : boost::process::detail::posix::async_handler
0025 {
0026     std::function<void(int, const std::error_code&)> handler;
0027     on_exit_(const std::function<void(int, const std::error_code&)> & handler) : handler(handler)
0028     {
0029     }
0030 
0031     template<typename Executor>
0032     std::function<void(int, const std::error_code&)> on_exit_handler(Executor& exec)
0033     {
0034         auto v = boost::asio::prefer(boost::process::detail::get_io_context(exec.seq).get_executor(),
0035                                      boost::asio::execution::outstanding_work.tracked);
0036         auto handler_ = this->handler;
0037         return
0038             [handler_, v](int exit_code, const std::error_code & ec)
0039             {
0040                 handler_(exit_code, ec);
0041             };
0042 
0043     }
0044 };
0045 
0046 
0047 }}}}
0048 #endif /* BOOST_PROCESS_POSIX_ON_EXIT_HPP_ */