]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/fiber/src/future.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / fiber / src / future.cpp
CommitLineData
7c673cae
FG
1
2// Copyright Oliver Kowalke 2013.
3// Distributed under the Boost Software License, Version 1.0.
4// (See accompanying file LICENSE_1_0.txt or copy at
5// http://www.boost.org/LICENSE_1_0.txt)
6
7#include "boost/fiber/exceptions.hpp"
8
9namespace boost {
10namespace fibers {
11
12class future_error_category : public std::error_category {
13public:
14 virtual const char* name() const noexcept {
15 return "fiber-future";
16 }
17
18 virtual std::error_condition default_error_condition( int ev) const noexcept {
19 switch ( static_cast< future_errc >( ev) ) {
20 case future_errc::broken_promise:
b32b8144 21 return std::error_condition{
7c673cae 22 static_cast< int >( future_errc::broken_promise),
b32b8144 23 future_category() };
7c673cae 24 case future_errc::future_already_retrieved:
b32b8144 25 return std::error_condition{
7c673cae 26 static_cast< int >( future_errc::future_already_retrieved),
b32b8144 27 future_category() };
7c673cae 28 case future_errc::promise_already_satisfied:
b32b8144 29 return std::error_condition{
7c673cae 30 static_cast< int >( future_errc::promise_already_satisfied),
b32b8144 31 future_category() };
7c673cae 32 case future_errc::no_state:
b32b8144 33 return std::error_condition{
7c673cae
FG
34 static_cast<
35 int >( future_errc::no_state),
b32b8144 36 future_category() };
7c673cae 37 default:
b32b8144 38 return std::error_condition{ ev, * this };
7c673cae
FG
39 }
40 }
41
42 virtual bool equivalent( std::error_code const& code, int condition) const noexcept {
43 return * this == code.category() &&
44 static_cast< int >( default_error_condition( code.value() ).value() ) == condition;
45 }
46
47 virtual std::string message( int ev) const {
48 switch ( static_cast< future_errc >( ev) ) {
49 case future_errc::broken_promise:
b32b8144
FG
50 return std::string{ "The associated promise has been destructed prior "
51 "to the associated state becoming ready." };
7c673cae 52 case future_errc::future_already_retrieved:
b32b8144
FG
53 return std::string{ "The future has already been retrieved from "
54 "the promise or packaged_task." };
7c673cae 55 case future_errc::promise_already_satisfied:
b32b8144 56 return std::string{ "The state of the promise has already been set." };
7c673cae 57 case future_errc::no_state:
b32b8144
FG
58 return std::string{ "Operation not permitted on an object without "
59 "an associated state." };
7c673cae 60 }
b32b8144 61 return std::string{ "unspecified future_errc value\n" };
7c673cae
FG
62 }
63};
64
65BOOST_FIBERS_DECL
66std::error_category const& future_category() noexcept {
67 static fibers::future_error_category cat;
68 return cat;
69}
70
71}}