1e4b17023SJohn Marino // future -*- C++ -*- 2e4b17023SJohn Marino 3e4b17023SJohn Marino // Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc. 4e4b17023SJohn Marino // 5e4b17023SJohn Marino // This file is part of the GNU ISO C++ Library. This library is free 6e4b17023SJohn Marino // software; you can redistribute it and/or modify it under the 7e4b17023SJohn Marino // terms of the GNU General Public License as published by the 8e4b17023SJohn Marino // Free Software Foundation; either version 3, or (at your option) 9e4b17023SJohn Marino // any later version. 10e4b17023SJohn Marino 11e4b17023SJohn Marino // This library is distributed in the hope that it will be useful, 12e4b17023SJohn Marino // but WITHOUT ANY WARRANTY; without even the implied warranty of 13e4b17023SJohn Marino // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14e4b17023SJohn Marino // GNU General Public License for more details. 15e4b17023SJohn Marino 16e4b17023SJohn Marino // Under Section 7 of GPL version 3, you are granted additional 17e4b17023SJohn Marino // permissions described in the GCC Runtime Library Exception, version 18e4b17023SJohn Marino // 3.1, as published by the Free Software Foundation. 19e4b17023SJohn Marino 20e4b17023SJohn Marino // You should have received a copy of the GNU General Public License and 21e4b17023SJohn Marino // a copy of the GCC Runtime Library Exception along with this program; 22e4b17023SJohn Marino // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 23e4b17023SJohn Marino // <http://www.gnu.org/licenses/>. 24e4b17023SJohn Marino 25e4b17023SJohn Marino #include <future> 26e4b17023SJohn Marino 27e4b17023SJohn Marino namespace 28e4b17023SJohn Marino { 29e4b17023SJohn Marino struct future_error_category : public std::error_category 30e4b17023SJohn Marino { 31e4b17023SJohn Marino virtual const char* name__anon9a39f4520111::future_error_category32e4b17023SJohn Marino name() const noexcept 33e4b17023SJohn Marino { return "future"; } 34e4b17023SJohn Marino message__anon9a39f4520111::future_error_category35e4b17023SJohn Marino virtual std::string message(int __ec) const 36e4b17023SJohn Marino { 37e4b17023SJohn Marino std::string __msg; 38e4b17023SJohn Marino switch (std::future_errc(__ec)) 39e4b17023SJohn Marino { 40e4b17023SJohn Marino case std::future_errc::broken_promise: 41e4b17023SJohn Marino __msg = "Broken promise"; 42e4b17023SJohn Marino break; 43e4b17023SJohn Marino case std::future_errc::future_already_retrieved: 44e4b17023SJohn Marino __msg = "Future already retrieved"; 45e4b17023SJohn Marino break; 46e4b17023SJohn Marino case std::future_errc::promise_already_satisfied: 47e4b17023SJohn Marino __msg = "Promise already satisfied"; 48e4b17023SJohn Marino break; 49e4b17023SJohn Marino case std::future_errc::no_state: 50e4b17023SJohn Marino __msg = "No associated state"; 51e4b17023SJohn Marino break; 52e4b17023SJohn Marino default: 53e4b17023SJohn Marino __msg = "Unknown error"; 54e4b17023SJohn Marino break; 55e4b17023SJohn Marino } 56e4b17023SJohn Marino return __msg; 57e4b17023SJohn Marino } 58e4b17023SJohn Marino }; 59e4b17023SJohn Marino 60e4b17023SJohn Marino const future_error_category& __future_category_instance()61e4b17023SJohn Marino __future_category_instance() noexcept 62e4b17023SJohn Marino { 63*95d28233SJohn Marino static const future_error_category __fec{}; 64e4b17023SJohn Marino return __fec; 65e4b17023SJohn Marino } 66e4b17023SJohn Marino } 67e4b17023SJohn Marino 68e4b17023SJohn Marino namespace std _GLIBCXX_VISIBILITY(default) 69e4b17023SJohn Marino { 70e4b17023SJohn Marino _GLIBCXX_BEGIN_NAMESPACE_VERSION 71e4b17023SJohn Marino future_category()72e4b17023SJohn Marino const error_category& future_category() noexcept 73e4b17023SJohn Marino { return __future_category_instance(); } 74e4b17023SJohn Marino ~future_error()75e4b17023SJohn Marino future_error::~future_error() noexcept { } 76e4b17023SJohn Marino 77e4b17023SJohn Marino const char* what() const78e4b17023SJohn Marino future_error::what() const noexcept { return _M_code.message().c_str(); } 79e4b17023SJohn Marino 80e4b17023SJohn Marino #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) \ 81e4b17023SJohn Marino && (ATOMIC_INT_LOCK_FREE > 1) 82e4b17023SJohn Marino __future_base::_Result_base::_Result_base() = default; 83e4b17023SJohn Marino 84e4b17023SJohn Marino __future_base::_Result_base::~_Result_base() = default; 85e4b17023SJohn Marino 86e4b17023SJohn Marino __future_base::_State_base::~_State_base() = default; 87e4b17023SJohn Marino #endif 88e4b17023SJohn Marino 89e4b17023SJohn Marino _GLIBCXX_END_NAMESPACE_VERSION 90e4b17023SJohn Marino } // namespace std 91