]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/fiber/src/future.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / fiber / src / future.cpp
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
9 namespace boost {
10 namespace fibers {
11
12 class future_error_category : public std::error_category {
13 public:
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:
21 return std::error_condition{
22 static_cast< int >( future_errc::broken_promise),
23 future_category() };
24 case future_errc::future_already_retrieved:
25 return std::error_condition{
26 static_cast< int >( future_errc::future_already_retrieved),
27 future_category() };
28 case future_errc::promise_already_satisfied:
29 return std::error_condition{
30 static_cast< int >( future_errc::promise_already_satisfied),
31 future_category() };
32 case future_errc::no_state:
33 return std::error_condition{
34 static_cast<
35 int >( future_errc::no_state),
36 future_category() };
37 default:
38 return std::error_condition{ ev, * this };
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:
50 return std::string{ "The associated promise has been destructed prior "
51 "to the associated state becoming ready." };
52 case future_errc::future_already_retrieved:
53 return std::string{ "The future has already been retrieved from "
54 "the promise or packaged_task." };
55 case future_errc::promise_already_satisfied:
56 return std::string{ "The state of the promise has already been set." };
57 case future_errc::no_state:
58 return std::string{ "Operation not permitted on an object without "
59 "an associated state." };
60 }
61 return std::string{ "unspecified future_errc value\n" };
62 }
63 };
64
65 BOOST_FIBERS_DECL
66 std::error_category const& future_category() noexcept {
67 static fibers::future_error_category cat;
68 return cat;
69 }
70
71 }}