You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2016/07/05 22:06:17 UTC
[4/4] mesos git commit: Extended install() to support 7 arguments.
Extended install() to support 7 arguments.
Review: https://reviews.apache.org/r/49606/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/90bcedce
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/90bcedce
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/90bcedce
Branch: refs/heads/master
Commit: 90bcedcef22c960a08cc7056253d2b05d9a4ad81
Parents: c5e2aae
Author: Joerg Schad <jo...@mesosphere.io>
Authored: Tue Jul 5 17:05:21 2016 -0500
Committer: Vinod Kone <vi...@gmail.com>
Committed: Tue Jul 5 17:06:05 2016 -0500
----------------------------------------------------------------------
.../libprocess/include/process/protobuf.hpp | 132 +++++++++++++++++++
1 file changed, 132 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/90bcedce/3rdparty/libprocess/include/process/protobuf.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/protobuf.hpp b/3rdparty/libprocess/include/process/protobuf.hpp
index d478cc0..78ff40e 100644
--- a/3rdparty/libprocess/include/process/protobuf.hpp
+++ b/3rdparty/libprocess/include/process/protobuf.hpp
@@ -273,6 +273,35 @@ 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>
+ void install(
+ void (T::*method)(const process::UPID&, P1C, P2C, P3C,
+ P4C, P5C, P6C, P7C),
+ 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)
+ {
+ google::protobuf::Message* m = new M();
+ T* t = static_cast<T*>(this);
+ protobufHandlers[m->GetTypeName()] =
+ lambda::bind(&handler7<M, P1, P1C, P2, P2C, P3, P3C,
+ P4, P4C, P5, P5C, P6, P6C, P7, P7C>,
+ t, method, p1, p2, p3, p4, p5, p6, p7,
+ lambda::_1, lambda::_2);
+ delete m;
+ }
+
// Installs that do not take the sender.
template <typename M>
void install(void (T::*method)(const M&))
@@ -419,6 +448,34 @@ 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>
+ void install(
+ void (T::*method)(P1C, P2C, P3C, P4C, P5C, P6C, P7C),
+ 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)
+ {
+ google::protobuf::Message* m = new M();
+ T* t = static_cast<T*>(this);
+ protobufHandlers[m->GetTypeName()] =
+ lambda::bind(&_handler7<M, P1, P1C, P2, P2C, P3, P3C,
+ P4, P4C, P5, P5C, P6, P6C, P7, P7C>,
+ t, method, p1, p2, p3, p4, p5, p6, p7,
+ lambda::_1, lambda::_2);
+ delete m;
+ }
+
using process::Process<T>::install;
private:
@@ -613,6 +670,44 @@ 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>
+ static void handler7(
+ T* t,
+ void (T::*method)(
+ const process::UPID&, P1C, P2C, P3C, P4C, P5C, P6C, P7C),
+ 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,
+ 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)()));
+ } else {
+ LOG(WARNING) << "Initialization errors: "
+ << m.InitializationErrorString();
+ }
+ }
// Handlers that ignore the sender.
template <typename M>
@@ -800,6 +895,43 @@ 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>
+ static void _handler7(
+ T* t,
+ void (T::*method)(P1C, P2C, P3C, P4C, P5C, P6C, P7C),
+ 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,
+ const process::UPID&,
+ const std::string& data)
+ {
+ M m;
+ m.ParseFromString(data);
+ if (m.IsInitialized()) {
+ (t->*method)(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)()));
+ } else {
+ LOG(WARNING) << "Initialization errors: "
+ << m.InitializationErrorString();
+ }
+ }
+
typedef lambda::function<
void(const process::UPID&, const std::string&)> handler;
hashmap<std::string, handler> protobufHandlers;