Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Unified Diff: webrtc/base/messagehandler.h

Issue 2681283002: Add ability to return moved value from FunctorMessageHandler, Optional. (Closed)
Patch Set: Rename to MoveValue as suggested. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/base/optional.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/messagehandler.h
diff --git a/webrtc/base/messagehandler.h b/webrtc/base/messagehandler.h
index 6a3c2ef7402bdf9203ef350dcff740f806d1210d..72c0dc6907950a8e0645f1172f7db9a503b16874 100644
--- a/webrtc/base/messagehandler.h
+++ b/webrtc/base/messagehandler.h
@@ -45,23 +45,13 @@ class FunctorMessageHandler : public MessageHandler {
}
const ReturnT& result() const { return result_; }
- private:
- FunctorT functor_;
- ReturnT result_;
-};
-
-// Specialization for std::unique_ptr<ReturnT>.
-template <class ReturnT, class FunctorT>
-class FunctorMessageHandler<class std::unique_ptr<ReturnT>, FunctorT>
- : public MessageHandler {
- public:
- explicit FunctorMessageHandler(const FunctorT& functor) : functor_(functor) {}
- virtual void OnMessage(Message* msg) { result_ = std::move(functor_()); }
- std::unique_ptr<ReturnT> result() { return std::move(result_); }
+ // Returns moved result. Should not call result() or MoveResult() again
+ // after this.
+ ReturnT MoveResult() { return std::move(result_); }
private:
FunctorT functor_;
- std::unique_ptr<ReturnT> result_;
+ ReturnT result_;
};
// Specialization for ReturnT of void.
@@ -74,6 +64,7 @@ class FunctorMessageHandler<void, FunctorT> : public MessageHandler {
functor_();
}
void result() const {}
+ void MoveResult() {}
private:
FunctorT functor_;
« no previous file with comments | « no previous file | webrtc/base/optional.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698