From b6407261ff7738ea4bd6cb7f3a620bc82931f9b1 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 16 Jun 2018 22:50:51 +0200 Subject: [PATCH 1/1] snake_case xbt/future.hpp --- doc/doxygen/uhood_switch.doc | 2 +- include/simgrid/kernel/future.hpp | 36 +++++++++++++++++++++---------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/doc/doxygen/uhood_switch.doc b/doc/doxygen/uhood_switch.doc index 684eacbb20..ac1b6faa0c 100644 --- a/doc/doxygen/uhood_switch.doc +++ b/doc/doxygen/uhood_switch.doc @@ -200,7 +200,7 @@ The crux of `future.then()` is: @code{cpp} template template -auto simgrid::kernel::Future::thenNoUnwrap(F continuation) +auto simgrid::kernel::Future::then_no_unwrap(F continuation) -> Future { typedef decltype(continuation(std::move(*this))) R; diff --git a/include/simgrid/kernel/future.hpp b/include/simgrid/kernel/future.hpp index bc45b509b5..766293985a 100644 --- a/include/simgrid/kernel/future.hpp +++ b/include/simgrid/kernel/future.hpp @@ -204,8 +204,7 @@ public: } }; -template -void bindPromise(Promise promise, Future future) +template void bind_promise(Promise promise, Future future) { class PromiseBinder { public: @@ -218,7 +217,18 @@ void bindPromise(Promise promise, Future future) future.then_(PromiseBinder(std::move(promise))); } -template Future unwrapFuture(Future> future); +template Future unwrap_future(Future> future); + +template +XBT_ATTRIB_DEPRECATED_v323("Please use bind_promise") void bindPromise(Promise promise, Future future) +{ + bind_promise(promise, future); +} +template +XBT_ATTRIB_DEPRECATED_v323("Please use unwrap_future") Future unwrapFuture(Future> future) +{ + unwrap_future(future); +} /** Result of some (probably) asynchronous operation in the SimGrid kernel * @@ -332,9 +342,7 @@ public: * * This version never does future unwrapping. */ - template - auto thenNoUnwrap(F continuation) - -> Future + template auto then_no_unwrap(F continuation) -> Future { typedef decltype(continuation(std::move(*this))) R; if (state_ == nullptr) @@ -354,6 +362,13 @@ public: return std::move(future); } + template + XBT_ATTRIB_DEPRECATED_v323("Please use then_no_unwrap") auto thenNoUnwrap(F continuation) + -> Future + { + then_no_unwrap(continuation); + } + /** Attach a continuation to this future * * The future must be valid in order to make this call. @@ -368,7 +383,7 @@ public: auto then(F continuation) -> typename std::enable_if::value, Future>::type { - return this->thenNoUnwrap(std::move(continuation)); + return this->then_no_unwrap(std::move(continuation)); } /** Attach a continuation to this future (future chaining) */ @@ -379,7 +394,7 @@ public: decltype(continuation(std::move(*this))) >::type { - return unwrapFuture(this->thenNoUnwap(std::move(continuation))); + return unwrap_future(this->then_no_unwrap(std::move(continuation))); } /** Get the value from the future @@ -405,12 +420,11 @@ private: std::shared_ptr> state_; }; -template -Future unwrapFuture(Future> future) +template Future unwrap_future(Future> future) { Promise promise; Future result = promise.get_future(); - bindPromise(std::move(promise), std::move(future)); + bind_promise(std::move(promise), std::move(future)); return std::move(result); } -- 2.20.1