X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f135812513aa29b0019faab8ab5d9b4201058f32..2e60fe3cfd5cf5305888fcca0ae19700d808bb23:/include/xbt/future.hpp diff --git a/include/xbt/future.hpp b/include/xbt/future.hpp index 8422e5fb74..ac75bf6747 100644 --- a/include/xbt/future.hpp +++ b/include/xbt/future.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2015-2019. The SimGrid Team. +/* Copyright (c) 2015-2020. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -12,6 +12,7 @@ #include #include #include +#include // std::future_error #include #include #include @@ -66,9 +67,10 @@ public: break; } default: - throw std::logic_error("Invalid result"); + throw std::future_error(std::future_errc::no_state); } } + private: boost::variant value_; }; @@ -125,19 +127,8 @@ template auto fulfill_promise(R& promise, F&& code) -> declty promise.set_exception(std::current_exception()); } } -template -XBT_ATTRIB_DEPRECATED_v323("Please use xbt::fulfill_promise()") auto fulfillPromise(R& promise, F&& code) - -> decltype(promise.set_value(code())) -{ - try { - promise.set_value(std::forward(code)()); - } - catch(...) { - promise.set_exception(std::current_exception()); - } -} -template auto fulfill_promise(P& promise, F&& code) -> decltype(promise.set_value()) +template auto fulfill_promise(R& promise, F&& code) -> decltype(promise.set_value()) { try { std::forward(code)(); @@ -146,18 +137,6 @@ template auto fulfill_promise(P& promise, F&& code) -> declty promise.set_exception(std::current_exception()); } } -template -XBT_ATTRIB_DEPRECATED_v323("Please use xbt::fulfill_promise()") auto fulfillPromise(P& promise, F&& code) - -> decltype(promise.set_value()) -{ - try { - std::forward(code)(); - promise.set_value(); - } - catch(...) { - promise.set_exception(std::current_exception()); - } -} /** Set a promise/result from a future/result *