diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index 5d5bb816..7dc3b843 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -33,7 +33,6 @@ lib boost_fiber context.cpp detail/spinlock.cpp fiber.cpp - future.cpp interruption.cpp mutex.cpp properties.cpp diff --git a/include/boost/fiber/exceptions.hpp b/include/boost/fiber/exceptions.hpp index b02d68ae..c8990069 100644 --- a/include/boost/fiber/exceptions.hpp +++ b/include/boost/fiber/exceptions.hpp @@ -9,6 +9,7 @@ #ifndef BOOST_fiber_EXCEPTIONS_H #define BOOST_fiber_EXCEPTIONS_H +#include #include #include #include @@ -158,39 +159,8 @@ public: } }; -enum class future_errc { - unknown = 0, - broken_promise, - future_already_retrieved, - promise_already_satisfied, - no_state -}; - -BOOST_FIBERS_DECL -std::error_category const& future_category() noexcept; - -}} - -namespace std { - -template<> -struct is_error_code_enum< boost::fibers::future_errc > : public true_type { -}; - -inline -std::error_code make_error_code( boost::fibers::future_errc e) noexcept { - return std::error_code( static_cast< int >( e), boost::fibers::future_category() ); -} - -inline -std::error_condition make_error_condition( boost::fibers::future_errc e) noexcept { - return std::error_condition( static_cast< int >( e), boost::fibers::future_category() ); -} - -} - -namespace boost { -namespace fibers { +using std::future_errc; +using std::future_category; class future_error : public std::logic_error { private: diff --git a/src/future.cpp b/src/future.cpp index 1fe1afb8..f251058b 100644 --- a/src/future.cpp +++ b/src/future.cpp @@ -9,63 +9,9 @@ namespace boost { namespace fibers { -class future_error_category : public std::error_category { -public: - virtual const char* name() const noexcept { - return "future"; - } - - virtual std::error_condition default_error_condition( int ev) const noexcept { - switch ( ev) { - case 1: return std::error_condition( - static_cast< int >( future_errc::broken_promise), - future_category() ); - case 2: return std::error_condition( - static_cast< int >( future_errc::future_already_retrieved), - future_category() ); - case 3: return std::error_condition( - static_cast< int >( future_errc::promise_already_satisfied), - future_category() ); - case 4: return std::error_condition( - static_cast< - int >( future_errc::no_state), - future_category() ); - default: - return std::error_condition( - static_cast< - int >( future_errc::unknown), - future_category() ); - } - } - - virtual bool equivalent( std::error_code const& code, int condition) const noexcept { - return * this == code.category() && - static_cast< int >( default_error_condition( code.value() ).value() ) == condition; - } - - virtual std::string message( int ev) const { - switch ( static_cast< future_errc >( ev) ) { - case future_errc::unknown: - return std::string("Unknown error"); - case future_errc::broken_promise: - return std::string("The associated promise has been destructed prior " - "to the associated state becoming ready."); - case future_errc::future_already_retrieved: - return std::string("The future has already been retrieved from " - "the promise or packaged_task."); - case future_errc::promise_already_satisfied: - return std::string("The state of the promise has already been set."); - case future_errc::no_state: - return std::string("Operation not permitted on an object without " - "an associated state."); - } - return std::string("unspecified future_errc value\n"); - } -}; - BOOST_FIBERS_DECL std::error_category const& future_category() noexcept { - static fibers::future_error_category cat; + static std::future_error_category cat; return cat; }