| 1 | // (C) Copyright 2012 Vicente J. Botet Escriba |
|---|---|
| 2 | // Use, modification and distribution are subject to the |
| 3 | // Boost Software License, Version 1.0. (See accompanying file |
| 4 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 5 | |
| 6 | #include <boost/thread/detail/config.hpp> |
| 7 | |
| 8 | #ifndef BOOST_NO_EXCEPTIONS |
| 9 | |
| 10 | #include <boost/thread/futures/future_error_code.hpp> |
| 11 | #include <string> |
| 12 | |
| 13 | namespace boost |
| 14 | { |
| 15 | |
| 16 | namespace thread_detail |
| 17 | { |
| 18 | |
| 19 | class future_error_category : |
| 20 | public boost::system::error_category |
| 21 | { |
| 22 | public: |
| 23 | virtual const char* name() const BOOST_NOEXCEPT; |
| 24 | virtual std::string message(int ev) const; |
| 25 | }; |
| 26 | |
| 27 | const char* |
| 28 | future_error_category::name() const BOOST_NOEXCEPT |
| 29 | { |
| 30 | return "future"; |
| 31 | } |
| 32 | |
| 33 | std::string |
| 34 | future_error_category::message(int ev) const |
| 35 | { |
| 36 | switch (BOOST_SCOPED_ENUM_NATIVE(future_errc)(ev)) |
| 37 | { |
| 38 | case future_errc::broken_promise: |
| 39 | return std::string("The associated promise has been destructed prior " |
| 40 | "to the associated state becoming ready."); |
| 41 | case future_errc::future_already_retrieved: |
| 42 | return std::string("The future has already been retrieved from " |
| 43 | "the promise or packaged_task."); |
| 44 | case future_errc::promise_already_satisfied: |
| 45 | return std::string("The state of the promise has already been set."); |
| 46 | case future_errc::no_state: |
| 47 | return std::string("Operation not permitted on an object without " |
| 48 | "an associated state."); |
| 49 | } |
| 50 | return std::string("unspecified future_errc value\n"); |
| 51 | } |
| 52 | future_error_category future_error_category_var; |
| 53 | } |
| 54 | |
| 55 | BOOST_THREAD_DECL |
| 56 | const system::error_category& |
| 57 | future_category() BOOST_NOEXCEPT |
| 58 | { |
| 59 | return thread_detail::future_error_category_var; |
| 60 | } |
| 61 | |
| 62 | } |
| 63 | #endif |
| 64 | |
| 65 |
