You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2017/01/26 20:16:45 UTC
[2/4] mesos git commit: Added a `install` template method to support
8 arguments.
Added a `install` template method to support 8 arguments.
Review: https://reviews.apache.org/r/55945/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/a66bd870
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/a66bd870
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/a66bd870
Branch: refs/heads/master
Commit: a66bd8704b8592289105b751861355fa9b372119
Parents: 5fc7bd5
Author: Jay Guo <gu...@gmail.com>
Authored: Thu Jan 26 12:00:38 2017 -0800
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Thu Jan 26 12:01:01 2017 -0800
----------------------------------------------------------------------
.../libprocess/include/process/protobuf.hpp | 74 ++++++++++++++++++++
1 file changed, 74 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/a66bd870/3rdparty/libprocess/include/process/protobuf.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/protobuf.hpp b/3rdparty/libprocess/include/process/protobuf.hpp
index ad2f232..ba6e6d6 100644
--- a/3rdparty/libprocess/include/process/protobuf.hpp
+++ b/3rdparty/libprocess/include/process/protobuf.hpp
@@ -304,6 +304,38 @@ protected:
delete m;
}
+ template <typename M,
+ typename P1, typename P1C,
+ typename P2, typename P2C,
+ typename P3, typename P3C,
+ typename P4, typename P4C,
+ typename P5, typename P5C,
+ typename P6, typename P6C,
+ typename P7, typename P7C,
+ typename P8, typename P8C>
+ void install(
+ void (T::*method)(const process::UPID&, P1C, P2C, P3C,
+ P4C, P5C, P6C, P7C, P8C),
+ P1 (M::*p1)() const,
+ P2 (M::*p2)() const,
+ P3 (M::*p3)() const,
+ P4 (M::*p4)() const,
+ P5 (M::*p5)() const,
+ P6 (M::*p6)() const,
+ P7 (M::*p7)() const,
+ P8 (M::*p8)() const)
+ {
+ google::protobuf::Message* m = new M();
+ T* t = static_cast<T*>(this);
+ protobufHandlers[m->GetTypeName()] =
+ lambda::bind(&handler8<M, P1, P1C, P2, P2C, P3, P3C,
+ P4, P4C, P5, P5C, P6, P6C,
+ P7, P7C, P8, P8C>,
+ t, method, p1, p2, p3, p4, p5, p6, p7, p8,
+ lambda::_1, lambda::_2);
+ delete m;
+ }
+
// Installs that do not take the sender.
template <typename M>
void install(void (T::*method)(const M&))
@@ -711,6 +743,48 @@ private:
}
}
+ template <typename M,
+ typename P1, typename P1C,
+ typename P2, typename P2C,
+ typename P3, typename P3C,
+ typename P4, typename P4C,
+ typename P5, typename P5C,
+ typename P6, typename P6C,
+ typename P7, typename P7C,
+ typename P8, typename P8C>
+ static void handler8(
+ T* t,
+ void (T::*method)(
+ const process::UPID&, P1C, P2C, P3C, P4C, P5C, P6C, P7C, P8C),
+ P1 (M::*p1)() const,
+ P2 (M::*p2)() const,
+ P3 (M::*p3)() const,
+ P4 (M::*p4)() const,
+ P5 (M::*p5)() const,
+ P6 (M::*p6)() const,
+ P7 (M::*p7)() const,
+ P8 (M::*p8)() const,
+ const process::UPID& sender,
+ const std::string& data)
+ {
+ M m;
+ m.ParseFromString(data);
+ if (m.IsInitialized()) {
+ (t->*method)(sender,
+ google::protobuf::convert((&m->*p1)()),
+ google::protobuf::convert((&m->*p2)()),
+ google::protobuf::convert((&m->*p3)()),
+ google::protobuf::convert((&m->*p4)()),
+ google::protobuf::convert((&m->*p5)()),
+ google::protobuf::convert((&m->*p6)()),
+ google::protobuf::convert((&m->*p7)()),
+ google::protobuf::convert((&m->*p8)()));
+ } else {
+ LOG(WARNING) << "Initialization errors: "
+ << m.InitializationErrorString();
+ }
+ }
+
// Handlers that ignore the sender.
template <typename M>
static void _handlerM(