From d8a6ade96189b3973b4bd7a94e719c07a28008f9 Mon Sep 17 00:00:00 2001
From: Florian Fischer <florian.fischer@muhq.space>
Date: Mon, 3 May 2021 14:08:11 +0200
Subject: [PATCH] [Future] remove not used rvalue reference setCallback

---
 emper/io/Future.hpp             | 28 +++++-----------------------
 tests/io/FutureCallbackTest.cpp | 10 ++++------
 2 files changed, 9 insertions(+), 29 deletions(-)

diff --git a/emper/io/Future.hpp b/emper/io/Future.hpp
index 2f8afc7f..4bac70ce 100644
--- a/emper/io/Future.hpp
+++ b/emper/io/Future.hpp
@@ -56,10 +56,7 @@ class Future : public Logger<LogSubsystem::IO> {
 	 public:
 		workeraffinity_t affinity;
 
-		// store callback via copy
 		CallbackInternal(Callback callback) : callback(std::move(callback)) {}
-		// store callback via move
-		CallbackInternal(const Callback&& callback) : callback(callback) {}
 
 		void operator()(const int32_t& res) { callback(res); }
 	};
@@ -247,32 +244,17 @@ class Future : public Logger<LogSubsystem::IO> {
 		this->dependency = &dependency;
 	}
 
- private:
-	inline void setCallback(CallbackInternal* callback) {
-		if (unlikely(this->callback)) {
-			delete this->callback;
-		}
-
-		this->callback = callback;
-	}
-
- public:
 	/*
 	 * @brief register a callback which is executed in a new Fiber on completion
 	 *
 	 * @param callback Callback reference which is copied and executed on completion.
 	 *                 It gets passed the value causing the completion.
 	 */
-	inline void setCallback(const Callback& callback) { setCallback(new CallbackInternal(callback)); }
-
-	/*
-	 * @brief register a callback which is executed in a new Fiber on completion
-	 *
-	 * @param callback Callback rvalue which gets moved and executed on completion.
-	 *                 It gets passed the value causing the completion.
-	 */
-	inline void setCallback(const Callback&& callback) {
-		setCallback(new CallbackInternal(callback));
+	inline void setCallback(const Callback& callback) {
+		if (unlikely(this->callback)) {
+			delete this->callback;
+		}
+		this->callback = new CallbackInternal(callback);
 	}
 
 	/*
diff --git a/tests/io/FutureCallbackTest.cpp b/tests/io/FutureCallbackTest.cpp
index 4e7e85bb..a4a1dcd2 100644
--- a/tests/io/FutureCallbackTest.cpp
+++ b/tests/io/FutureCallbackTest.cpp
@@ -10,17 +10,15 @@
 using emper::io::AlarmFuture;
 using emper::io::Future;
 
-void callback(int32_t res, BPS& bps) {
-	assert(res == -ETIME);
-	bps.signal();
-}
-
 void emperTest() {
 	AlarmFuture::Timespec ts = {.tv_sec = 1, .tv_nsec = 0};
 	AlarmFuture alarm(ts);
 	BPS bps;
 
-	alarm.setCallback(Future::Callback([&bps](int32_t res) { callback(res, bps); }));
+	alarm.setCallback([&bps](int32_t res) {
+		assert(res == -ETIME);
+		bps.signal();
+	});
 	alarm.submit();
 
 	// wait till the callback was executed
-- 
GitLab