handler.hpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Copyright (c) 2016 Klemens D. Morgenstern
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_PROCESS_DETAIL_POSIX_HANDLER_HPP_
  6. #define BOOST_PROCESS_DETAIL_POSIX_HANDLER_HPP_
  7. #include <boost/process/detail/handler_base.hpp>
  8. namespace boost { namespace process { namespace detail { namespace posix {
  9. //does not extend anything.
  10. struct handler_base_ext : handler_base
  11. {
  12. template<typename Executor>
  13. void on_fork_error (Executor &, const std::error_code&) const {}
  14. template<typename Executor>
  15. void on_exec_setup (Executor &) const {}
  16. template<typename Executor>
  17. void on_exec_error (Executor &, const std::error_code&) const {}
  18. };
  19. template <class Handler>
  20. struct on_fork_error_ : handler_base_ext
  21. {
  22. explicit on_fork_error_(Handler handler) : handler_(handler) {}
  23. template <class Executor>
  24. void on_fork_error(Executor &e, const std::error_code &ec) const
  25. {
  26. handler_(e, ec);
  27. }
  28. private:
  29. Handler handler_;
  30. };
  31. template <class Handler>
  32. struct on_exec_setup_ : handler_base_ext
  33. {
  34. explicit on_exec_setup_(Handler handler) : handler_(handler) {}
  35. template <class Executor>
  36. void on_exec_setup(Executor &e) const
  37. {
  38. handler_(e);
  39. }
  40. private:
  41. Handler handler_;
  42. };
  43. template <class Handler>
  44. struct on_exec_error_ : handler_base_ext
  45. {
  46. explicit on_exec_error_(Handler handler) : handler_(handler) {}
  47. template <class Executor>
  48. void on_exec_error(Executor &e, const std::error_code &ec) const
  49. {
  50. handler_(e, ec);
  51. }
  52. private:
  53. Handler handler_;
  54. };
  55. }}}}
  56. #endif /* BOOST_PROCESS_DETAIL_POSIX_HANDLER_HPP_ */