2
0
mirror of https://github.com/boostorg/fiber.git synced 2026-02-15 00:52:34 +00:00

replace user-defined future_status+ future_errc by those of std

This commit is contained in:
Oliver Kowalke
2015-12-05 20:16:07 +01:00
parent 6d7b7d06c7
commit 117a55d8c6
3 changed files with 4 additions and 89 deletions

View File

@@ -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;
}