You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bb...@apache.org on 2018/05/24 12:39:51 UTC
mesos git commit: Reformated libprocess example code.
Repository: mesos
Updated Branches:
refs/heads/master 5248cb1c5 -> cb8a30bbd
Reformated libprocess example code.
Review: https://reviews.apache.org/r/67281/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/cb8a30bb
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/cb8a30bb
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/cb8a30bb
Branch: refs/heads/master
Commit: cb8a30bbd70d398d1c883514a3bdcf3a382e8f95
Parents: 5248cb1
Author: Benjamin Bannier <be...@mesosphere.io>
Authored: Thu May 24 14:37:26 2018 +0200
Committer: Benjamin Bannier <bb...@apache.org>
Committed: Thu May 24 14:37:26 2018 +0200
----------------------------------------------------------------------
3rdparty/libprocess/examples/example.cpp | 76 +++++++++++++--------------
1 file changed, 38 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/cb8a30bb/3rdparty/libprocess/examples/example.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/examples/example.cpp b/3rdparty/libprocess/examples/example.cpp
index a97665e..8c507ae 100644
--- a/3rdparty/libprocess/examples/example.cpp
+++ b/3rdparty/libprocess/examples/example.cpp
@@ -12,6 +12,7 @@
#include <iostream>
#include <sstream>
+#include <string>
#include <process/defer.hpp>
#include <process/dispatch.hpp>
@@ -34,7 +35,7 @@ public:
Future<int> func1()
{
promise.future().onAny(
- defer([=] (const Future<int>& future) {
+ defer([=](const Future<int>& future) {
terminate(self());
}));
return promise.future();
@@ -65,22 +66,22 @@ public:
protected:
virtual void initialize()
{
-// route("/vars", &MyProcess::vars);
- route("/vars", [=] (const Request& request) {
- string body = "... vars here ...";
- OK response;
- response.headers["Content-Type"] = "text/plain";
- std::ostringstream out;
- out << body.size();
- response.headers["Content-Length"] = out.str();
- response.body = body;
- return response;
- });
-
-// install("stop", &MyProcess::stop);
- install("stop", [=] (const UPID& from, const string& body) {
- terminate(self());
- });
+ // route("/vars", &MyProcess::vars);
+ route("/vars", [=](const Request& request) {
+ string body = "... vars here ...";
+ OK response;
+ response.headers["Content-Type"] = "text/plain";
+ std::ostringstream out;
+ out << body.size();
+ response.headers["Content-Length"] = out.str();
+ response.body = body;
+ return response;
+ });
+
+ // install("stop", &MyProcess::stop);
+ install("stop", [=](const UPID& from, const string& body) {
+ terminate(self());
+ });
}
private:
@@ -95,39 +96,38 @@ int main(int argc, char** argv)
PID<> pid2 = pid;
-// --------------------------------------
+ //// --------------------------------------
-// Future<int> future = dispatch(pid, &MyProcess::func1);
-// dispatch(pid, &MyProcess::func2, 42);
+ // Future<int> future = dispatch(pid, &MyProcess::func1);
+ // dispatch(pid, &MyProcess::func2, 42);
-// std::cout << future.get() << std::endl;
+ // std::cout << future.get() << std::endl;
-// post(pid, "stop");
+ // post(pid, "stop");
-// --------------------------------------
+ //// --------------------------------------
-// Promise<bool> p;
+ // Promise<bool> p;
-// dispatch(pid, &MyProcess::func1)
-// .then([=, &p] (int i) {
-// p.set(i == 42);
-// return p.future();
-// })
-// .then([=] (bool b) {
-// if (b) {
-// post(pid, "stop");
-// }
-// return true; // No Future<void>.
-// });
+ // dispatch(pid, &MyProcess::func1)
+ // .then([=, &p] (int i) {
+ // p.set(i == 42);
+ // return p.future();
+ // })
+ // .then([=] (bool b) {
+ // if (b) {
+ // post(pid, "stop");
+ // }
+ // return true; // No Future<void>.
+ // });
-// dispatch(pid, &MyProcess::func2, 42);
+ // dispatch(pid, &MyProcess::func2, 42);
-// --------------------------------------
+ //// --------------------------------------
dispatch(pid, &MyProcess::func1);
dispatch(pid, &MyProcess::func2, 42);
-
wait(pid);
return 0;
}