From 504e8ecc4d4245655dafaae23e56e64260b746ad Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Mon, 22 Feb 2021 11:33:39 +0100 Subject: [PATCH] Rename include/xbt/{future.hpp => promise.hpp}. Rationale: avoid confusion with include/simgrid/kernel/future.hpp in coverage measures. --- MANIFEST.in | 2 +- include/simgrid/kernel/future.hpp | 2 +- include/simgrid/simix.hpp | 2 +- include/simgrid/simix/blocking_simcall.hpp | 2 +- include/xbt/{future.hpp => promise.hpp} | 56 +++++-------------- .../simcall-generic/simcall-generic.cpp | 2 +- tools/cmake/DefinePackages.cmake | 2 +- 7 files changed, 19 insertions(+), 49 deletions(-) rename include/xbt/{future.hpp => promise.hpp} (78%) diff --git a/MANIFEST.in b/MANIFEST.in index 431acaabcd..afc88e4684 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2045,7 +2045,6 @@ include include/xbt/ex.h include include/xbt/file.hpp include include/xbt/function_types.h include include/xbt/functional.hpp -include include/xbt/future.hpp include include/xbt/graph.h include include/xbt/log.h include include/xbt/log.hpp @@ -2054,6 +2053,7 @@ include include/xbt/misc.h include include/xbt/module.h include include/xbt/parmap.h include include/xbt/parse_units.hpp +include include/xbt/promise.hpp include include/xbt/random.hpp include include/xbt/range.hpp include include/xbt/replay.hpp diff --git a/include/simgrid/kernel/future.hpp b/include/simgrid/kernel/future.hpp index b0be4b1e71..ec2c7a4ad8 100644 --- a/include/simgrid/kernel/future.hpp +++ b/include/simgrid/kernel/future.hpp @@ -17,7 +17,7 @@ #include #include -#include +#include namespace simgrid { namespace kernel { diff --git a/include/simgrid/simix.hpp b/include/simgrid/simix.hpp index dbafbfa8b9..b6bea161f7 100644 --- a/include/simgrid/simix.hpp +++ b/include/simgrid/simix.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include diff --git a/include/simgrid/simix/blocking_simcall.hpp b/include/simgrid/simix/blocking_simcall.hpp index b0258a28e0..8a4c433fe8 100644 --- a/include/simgrid/simix/blocking_simcall.hpp +++ b/include/simgrid/simix/blocking_simcall.hpp @@ -13,10 +13,10 @@ #include -#include #include #include #include +#include namespace simgrid { namespace simix { diff --git a/include/xbt/future.hpp b/include/xbt/promise.hpp similarity index 78% rename from include/xbt/future.hpp rename to include/xbt/promise.hpp index 0c850ee413..83f4e5336c 100644 --- a/include/xbt/future.hpp +++ b/include/xbt/promise.hpp @@ -4,8 +4,8 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#ifndef XBT_FUTURE_HPP -#define XBT_FUTURE_HPP +#ifndef XBT_PROMISE_HPP +#define XBT_PROMISE_HPP #include @@ -28,25 +28,12 @@ namespace xbt { * * Also the name is not so great. **/ -template -class Result { +template class Result { public: - bool is_valid() const - { - return value_.which() > 0; - } - void set_exception(std::exception_ptr e) - { - value_ = std::move(e); - } - void set_value(T&& value) - { - value_ = std::move(value); - } - void set_value(T const& value) - { - value_ = value; - } + bool is_valid() const { return value_.which() > 0; } + void set_exception(std::exception_ptr e) { value_ = std::move(e); } + void set_value(T&& value) { value_ = std::move(value); } + void set_value(T const& value) { value_ = value; } /** Extract the value from the future * @@ -75,32 +62,16 @@ private: boost::variant value_; }; -template<> -class Result : public Result -{ +template <> class Result : public Result { public: - void set_value() - { - Result::set_value(nullptr); - } - void get() - { - Result::get(); - } + void set_value() { Result::set_value(nullptr); } + void get() { Result::get(); } }; -template -class Result : public Result> -{ +template class Result : public Result> { public: - void set_value(T& value) - { - Result>::set_value(std::ref(value)); - } - T& get() - { - return Result>::get(); - } + void set_value(T& value) { Result>::set_value(std::ref(value)); } + T& get() { return Result>::get(); } }; /** Execute some code and set a promise or result accordingly @@ -156,7 +127,6 @@ template inline void set_promise(P& promise, F&& future) { fulfill_promise(promise, [&future] { return std::forward(future).get(); }); } - } } diff --git a/teshsuite/kernel/simcall-generic/simcall-generic.cpp b/teshsuite/kernel/simcall-generic/simcall-generic.cpp index c2a1ecd562..3e9adcf67c 100644 --- a/teshsuite/kernel/simcall-generic/simcall-generic.cpp +++ b/teshsuite/kernel/simcall-generic/simcall-generic.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index d66369ac1f..09b32f85c3 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -758,7 +758,6 @@ set(headers_to_install include/xbt/file.hpp include/xbt/functional.hpp include/xbt/function_types.h - include/xbt/future.hpp include/xbt/graph.h include/xbt/log.h include/xbt/log.hpp @@ -768,6 +767,7 @@ set(headers_to_install include/xbt/PropertyHolder.hpp include/xbt/parmap.h include/xbt/parse_units.hpp + include/xbt/promise.hpp include/xbt/range.hpp include/xbt/random.hpp include/xbt/replay.hpp -- 2.20.1