future_error.hpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // (C) Copyright 2008-10 Anthony Williams
  2. // (C) Copyright 2011-2015 Vicente J. Botet Escriba
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See
  5. // accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #ifndef BOOST_THREAD_FUTURES_FUTURE_ERROR_HPP
  8. #define BOOST_THREAD_FUTURES_FUTURE_ERROR_HPP
  9. #include <boost/thread/detail/config.hpp>
  10. #include <boost/thread/futures/future_error_code.hpp>
  11. #include <boost/system/error_code.hpp>
  12. #include <stdexcept>
  13. namespace boost
  14. {
  15. class BOOST_SYMBOL_VISIBLE future_error
  16. : public std::logic_error
  17. {
  18. system::error_code ec_;
  19. public:
  20. future_error(system::error_code ec)
  21. : logic_error(ec.message()),
  22. ec_(ec)
  23. {
  24. }
  25. const system::error_code& code() const BOOST_NOEXCEPT
  26. {
  27. return ec_;
  28. }
  29. };
  30. class BOOST_SYMBOL_VISIBLE future_uninitialized:
  31. public future_error
  32. {
  33. public:
  34. future_uninitialized() :
  35. future_error(system::make_error_code(future_errc::no_state))
  36. {}
  37. };
  38. class BOOST_SYMBOL_VISIBLE broken_promise:
  39. public future_error
  40. {
  41. public:
  42. broken_promise():
  43. future_error(system::make_error_code(future_errc::broken_promise))
  44. {}
  45. };
  46. class BOOST_SYMBOL_VISIBLE future_already_retrieved:
  47. public future_error
  48. {
  49. public:
  50. future_already_retrieved():
  51. future_error(system::make_error_code(future_errc::future_already_retrieved))
  52. {}
  53. };
  54. class BOOST_SYMBOL_VISIBLE promise_already_satisfied:
  55. public future_error
  56. {
  57. public:
  58. promise_already_satisfied():
  59. future_error(system::make_error_code(future_errc::promise_already_satisfied))
  60. {}
  61. };
  62. class BOOST_SYMBOL_VISIBLE task_already_started:
  63. public future_error
  64. {
  65. public:
  66. task_already_started():
  67. future_error(system::make_error_code(future_errc::promise_already_satisfied))
  68. {}
  69. };
  70. class BOOST_SYMBOL_VISIBLE task_moved:
  71. public future_error
  72. {
  73. public:
  74. task_moved():
  75. future_error(system::make_error_code(future_errc::no_state))
  76. {}
  77. };
  78. class promise_moved:
  79. public future_error
  80. {
  81. public:
  82. promise_moved():
  83. future_error(system::make_error_code(future_errc::no_state))
  84. {}
  85. };
  86. }
  87. #endif // header