C++11 lambda style updates for libprocess.
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/765b6c8e Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/765b6c8e Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/765b6c8e Branch: refs/heads/master Commit: 765b6c8eb96dc6368aa7febb89eed0f330ff50bc Parents: 944d501 Author: Benjamin Hindman <[email protected]> Authored: Sat May 2 10:24:16 2015 -0700 Committer: Benjamin Hindman <[email protected]> Committed: Sat May 2 10:28:20 2015 -0700 ---------------------------------------------------------------------- 3rdparty/libprocess/include/process/collect.hpp | 14 +++--- 3rdparty/libprocess/include/process/defer.hpp | 12 ++--- .../libprocess/include/process/deferred.hpp | 24 +++++----- 3rdparty/libprocess/include/process/delay.hpp | 4 +- .../libprocess/include/process/dispatch.hpp | 18 ++++---- 3rdparty/libprocess/include/process/future.hpp | 18 ++++---- 3rdparty/libprocess/src/io.cpp | 16 +++---- 3rdparty/libprocess/src/tests/process_tests.cpp | 46 ++++++++++---------- 8 files changed, 76 insertions(+), 76 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/765b6c8e/3rdparty/libprocess/include/process/collect.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/include/process/collect.hpp b/3rdparty/libprocess/include/process/collect.hpp index 1f10a92..c713c1b 100644 --- a/3rdparty/libprocess/include/process/collect.hpp +++ b/3rdparty/libprocess/include/process/collect.hpp @@ -204,15 +204,15 @@ Future<std::tuple<Future<T1>, Future<T2>>> await( Owned<Promise<Nothing>> promise1(new Promise<Nothing>()); Owned<Promise<Nothing>> promise2(new Promise<Nothing>()); - future1.onAny([=] () { promise1->set(Nothing()); }); - future2.onAny([=] () { promise2->set(Nothing()); }); + future1.onAny([=]() { promise1->set(Nothing()); }); + future2.onAny([=]() { promise2->set(Nothing()); }); std::list<Future<Nothing>> futures; futures.push_back(promise1->future()); futures.push_back(promise2->future()); return await(futures) - .then([=] () { return std::make_tuple(future1, future2); }); + .then([=]() { return std::make_tuple(future1, future2); }); } @@ -226,9 +226,9 @@ Future<std::tuple<Future<T1>, Future<T2>, Future<T3>>> await( Owned<Promise<Nothing>> promise2(new Promise<Nothing>()); Owned<Promise<Nothing>> promise3(new Promise<Nothing>()); - future1.onAny([=] () { promise1->set(Nothing()); }); - future2.onAny([=] () { promise2->set(Nothing()); }); - future3.onAny([=] () { promise3->set(Nothing()); }); + future1.onAny([=]() { promise1->set(Nothing()); }); + future2.onAny([=]() { promise2->set(Nothing()); }); + future3.onAny([=]() { promise3->set(Nothing()); }); std::list<Future<Nothing>> futures; futures.push_back(promise1->future()); @@ -236,7 +236,7 @@ Future<std::tuple<Future<T1>, Future<T2>, Future<T3>>> await( futures.push_back(promise3->future()); return await(futures) - .then([=] () { return std::make_tuple(future1, future2, future3); }); + .then([=]() { return std::make_tuple(future1, future2, future3); }); } } // namespace process { http://git-wip-us.apache.org/repos/asf/mesos/blob/765b6c8e/3rdparty/libprocess/include/process/defer.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/include/process/defer.hpp b/3rdparty/libprocess/include/process/defer.hpp index 7b4dd07..7c04736 100644 --- a/3rdparty/libprocess/include/process/defer.hpp +++ b/3rdparty/libprocess/include/process/defer.hpp @@ -24,7 +24,7 @@ Deferred<void(void)> defer( const PID<T>& pid, void (T::*method)(void)) { - return Deferred<void(void)>([=] () { + return Deferred<void(void)>([=]() { dispatch(pid, method); }); } @@ -64,7 +64,7 @@ Deferred<void(void)> defer( -> _Deferred<decltype(std::bind(&std::function<void(ENUM_PARAMS(N, P))>::operator(), std::function<void(ENUM_PARAMS(N, P))>(), ENUM_PARAMS(N, a)))> /* NOLINT(whitespace/line_length) */ \ { \ std::function<void(ENUM_PARAMS(N, P))> f( \ - [=] (ENUM_BINARY_PARAMS(N, P, p)) { \ + [=](ENUM_BINARY_PARAMS(N, P, p)) { \ dispatch(pid, method, ENUM_PARAMS(N, p)); \ }); \ return std::bind(&std::function<void(ENUM_PARAMS(N, P))>::operator(), std::move(f), ENUM_PARAMS(N, a)); /* NOLINT(whitespace/line_length) */ \ @@ -102,7 +102,7 @@ template <typename R, typename T> Deferred<Future<R>(void)> defer(const PID<T>& pid, Future<R> (T::*method)(void)) { - return Deferred<Future<R>(void)>([=] () { + return Deferred<Future<R>(void)>([=]() { return dispatch(pid, method); }); } @@ -132,7 +132,7 @@ defer(const Process<T>* process, Future<R> (T::*method)(void)) -> _Deferred<decltype(std::bind(&std::function<Future<R>(ENUM_PARAMS(N, P))>::operator(), std::function<Future<R>(ENUM_PARAMS(N, P))>(), ENUM_PARAMS(N, a)))> /* NOLINT(whitespace/line_length) */ \ { \ std::function<Future<R>(ENUM_PARAMS(N, P))> f( \ - [=] (ENUM_BINARY_PARAMS(N, P, p)) { \ + [=](ENUM_BINARY_PARAMS(N, P, p)) { \ return dispatch(pid, method, ENUM_PARAMS(N, p)); \ }); \ return std::bind(&std::function<Future<R>(ENUM_PARAMS(N, P))>::operator(), std::move(f), ENUM_PARAMS(N, a)); /* NOLINT(whitespace/line_length) */ \ @@ -172,7 +172,7 @@ template <typename R, typename T> Deferred<Future<R>(void)> defer(const PID<T>& pid, R (T::*method)(void)) { - return Deferred<Future<R>(void)>([=] () { + return Deferred<Future<R>(void)>([=]() { return dispatch(pid, method); }); } @@ -202,7 +202,7 @@ defer(const Process<T>* process, R (T::*method)(void)) -> _Deferred<decltype(std::bind(&std::function<Future<R>(ENUM_PARAMS(N, P))>::operator(), std::function<Future<R>(ENUM_PARAMS(N, P))>(), ENUM_PARAMS(N, a)))> /* NOLINT(whitespace/line_length) */ \ { \ std::function<Future<R>(ENUM_PARAMS(N, P))> f( \ - [=] (ENUM_BINARY_PARAMS(N, P, p)) { \ + [=](ENUM_BINARY_PARAMS(N, P, p)) { \ return dispatch(pid, method, ENUM_PARAMS(N, p)); \ }); \ return std::bind(&std::function<Future<R>(ENUM_PARAMS(N, P))>::operator(), std::move(f), ENUM_PARAMS(N, a)); /* NOLINT(whitespace/line_length) */ \ http://git-wip-us.apache.org/repos/asf/mesos/blob/765b6c8e/3rdparty/libprocess/include/process/deferred.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/include/process/deferred.hpp b/3rdparty/libprocess/include/process/deferred.hpp index 352205b..3746d69 100644 --- a/3rdparty/libprocess/include/process/deferred.hpp +++ b/3rdparty/libprocess/include/process/deferred.hpp @@ -71,7 +71,7 @@ struct _Deferred F f_ = f; return std::function<void()>( - [=] () { + [=]() { dispatch(pid_.get(), std::function<void()>(f_)); }); } @@ -86,7 +86,7 @@ struct _Deferred F f_ = f; return std::function<void()>( - [=] () { + [=]() { dispatch(pid_.get(), std::function<void()>(f_)); }); } @@ -102,7 +102,7 @@ struct _Deferred F f_ = f; return std::function<R()>( - [=] () { + [=]() { return dispatch(pid_.get(), std::function<R()>(f_)); }); } @@ -118,7 +118,7 @@ struct _Deferred F f_ = f; return std::function<R()>( - [=] () { + [=]() { return dispatch(pid_.get(), std::function<R()>(f_)); }); } @@ -141,8 +141,8 @@ struct _Deferred F f_ = f; \ \ return std::function<void(ENUM_PARAMS(N, P))>( \ - [=] (ENUM_BINARY_PARAMS(N, P, p)) { \ - std::function<void()> f__([=] () { \ + [=](ENUM_BINARY_PARAMS(N, P, p)) { \ + std::function<void()> f__([=]() { \ f_(ENUM_PARAMS(N, p)); \ }); \ dispatch(pid_.get(), f__); \ @@ -160,8 +160,8 @@ struct _Deferred F f_ = f; \ \ return std::function<void(ENUM_PARAMS(N, P))>( \ - [=] (ENUM_BINARY_PARAMS(N, P, p)) { \ - std::function<void()> f__([=] () { \ + [=](ENUM_BINARY_PARAMS(N, P, p)) { \ + std::function<void()> f__([=]() { \ f_(ENUM_PARAMS(N, p)); \ }); \ dispatch(pid_.get(), f__); \ @@ -183,8 +183,8 @@ struct _Deferred F f_ = f; \ \ return std::function<R(ENUM_PARAMS(N, P))>( \ - [=] (ENUM_BINARY_PARAMS(N, P, p)) { \ - std::function<R()> f__([=] () { \ + [=](ENUM_BINARY_PARAMS(N, P, p)) { \ + std::function<R()> f__([=]() { \ return f_(ENUM_PARAMS(N, p)); \ }); \ return dispatch(pid_.get(), f__); \ @@ -202,8 +202,8 @@ struct _Deferred F f_ = f; \ \ return std::function<R(ENUM_PARAMS(N, P))>( \ - [=] (ENUM_BINARY_PARAMS(N, P, p)) { \ - std::function<R()> f__([=] () { \ + [=](ENUM_BINARY_PARAMS(N, P, p)) { \ + std::function<R()> f__([=]() { \ return f_(ENUM_PARAMS(N, p)); \ }); \ return dispatch(pid_.get(), f__); \ http://git-wip-us.apache.org/repos/asf/mesos/blob/765b6c8e/3rdparty/libprocess/include/process/delay.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/include/process/delay.hpp b/3rdparty/libprocess/include/process/delay.hpp index 5818e83..29e3532 100644 --- a/3rdparty/libprocess/include/process/delay.hpp +++ b/3rdparty/libprocess/include/process/delay.hpp @@ -20,7 +20,7 @@ Timer delay(const Duration& duration, const PID<T>& pid, void (T::*method)()) { - return Clock::timer(duration, [=] () { + return Clock::timer(duration, [=]() { dispatch(pid, method); }); } @@ -53,7 +53,7 @@ Timer delay(const Duration& duration, void (T::*method)(ENUM_PARAMS(N, P)), \ ENUM_BINARY_PARAMS(N, A, a)) \ { \ - return Clock::timer(duration, [=] () { \ + return Clock::timer(duration, [=]() { \ dispatch(pid, method, ENUM_PARAMS(N, a)); \ }); \ } \ http://git-wip-us.apache.org/repos/asf/mesos/blob/765b6c8e/3rdparty/libprocess/include/process/dispatch.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/include/process/dispatch.hpp b/3rdparty/libprocess/include/process/dispatch.hpp index 99de0e9..617fd43 100644 --- a/3rdparty/libprocess/include/process/dispatch.hpp +++ b/3rdparty/libprocess/include/process/dispatch.hpp @@ -71,7 +71,7 @@ void dispatch( { std::shared_ptr<std::function<void(ProcessBase*)>> f( new std::function<void(ProcessBase*)>( - [=] (ProcessBase* process) { + [=](ProcessBase* process) { assert(process != NULL); T* t = dynamic_cast<T*>(process); assert(t != NULL); @@ -111,7 +111,7 @@ void dispatch( { \ std::shared_ptr<std::function<void(ProcessBase*)>> f( \ new std::function<void(ProcessBase*)>( \ - [=] (ProcessBase* process) { \ + [=](ProcessBase* process) { \ assert(process != NULL); \ T* t = dynamic_cast<T*>(process); \ assert(t != NULL); \ @@ -158,7 +158,7 @@ Future<R> dispatch( std::shared_ptr<std::function<void(ProcessBase*)>> f( new std::function<void(ProcessBase*)>( - [=] (ProcessBase* process) { + [=](ProcessBase* process) { assert(process != NULL); T* t = dynamic_cast<T*>(process); assert(t != NULL); @@ -200,7 +200,7 @@ Future<R> dispatch( \ std::shared_ptr<std::function<void(ProcessBase*)>> f( \ new std::function<void(ProcessBase*)>( \ - [=] (ProcessBase* process) { \ + [=](ProcessBase* process) { \ assert(process != NULL); \ T* t = dynamic_cast<T*>(process); \ assert(t != NULL); \ @@ -251,7 +251,7 @@ Future<R> dispatch( std::shared_ptr<std::function<void(ProcessBase*)>> f( new std::function<void(ProcessBase*)>( - [=] (ProcessBase* process) { + [=](ProcessBase* process) { assert(process != NULL); T* t = dynamic_cast<T*>(process); assert(t != NULL); @@ -293,7 +293,7 @@ Future<R> dispatch( \ std::shared_ptr<std::function<void(ProcessBase*)>> f( \ new std::function<void(ProcessBase*)>( \ - [=] (ProcessBase* process) { \ + [=](ProcessBase* process) { \ assert(process != NULL); \ T* t = dynamic_cast<T*>(process); \ assert(t != NULL); \ @@ -339,7 +339,7 @@ inline void dispatch( { std::shared_ptr<std::function<void(ProcessBase*)>> f_( new std::function<void(ProcessBase*)>( - [=] (ProcessBase*) { + [=](ProcessBase*) { f(); })); @@ -356,7 +356,7 @@ Future<R> dispatch( std::shared_ptr<std::function<void(ProcessBase*)>> f_( new std::function<void(ProcessBase*)>( - [=] (ProcessBase*) { + [=](ProcessBase*) { promise->associate(f()); })); @@ -375,7 +375,7 @@ Future<R> dispatch( std::shared_ptr<std::function<void(ProcessBase*)>> f_( new std::function<void(ProcessBase*)>( - [=] (ProcessBase*) { + [=](ProcessBase*) { promise->set(f()); })); http://git-wip-us.apache.org/repos/asf/mesos/blob/765b6c8e/3rdparty/libprocess/include/process/future.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/include/process/future.hpp b/3rdparty/libprocess/include/process/future.hpp index 851ceab..c22d6c8 100644 --- a/3rdparty/libprocess/include/process/future.hpp +++ b/3rdparty/libprocess/include/process/future.hpp @@ -198,7 +198,7 @@ private: const Future<T>& onReady(F&& f, Prefer) const { return onReady(std::function<void(const T&)>( - [=] (const T& t) mutable { + [=](const T& t) mutable { f(t); })); } @@ -207,7 +207,7 @@ private: const Future<T>& onReady(F&& f, LessPrefer) const { return onReady(std::function<void(const T&)>( - [=] (const T&) mutable { + [=](const T&) mutable { f(); })); } @@ -216,7 +216,7 @@ private: const Future<T>& onFailed(F&& f, Prefer) const { return onFailed(std::function<void(const std::string&)>( - [=] (const std::string& message) mutable { + [=](const std::string& message) mutable { f(message); })); } @@ -225,7 +225,7 @@ private: const Future<T>& onFailed(F&& f, LessPrefer) const { return onFailed(std::function<void(const std::string&)>( - [=] (const std::string&) mutable { + [=](const std::string&) mutable { f(); })); } @@ -234,7 +234,7 @@ private: const Future<T>& onAny(F&& f, Prefer) const { return onAny(std::function<void(const Future<T>&)>( - [=] (const Future<T>& future) mutable { + [=](const Future<T>& future) mutable { f(future); })); } @@ -243,7 +243,7 @@ private: const Future<T>& onAny(F&& f, LessPrefer) const { return onAny(std::function<void(const Future<T>&)>( - [=] (const Future<T>&) mutable { + [=](const Future<T>&) mutable { f(); })); } @@ -253,7 +253,7 @@ public: const Future<T>& onDiscard(F&& f) const { return onDiscard(std::function<void()>( - [=] () mutable { + [=]() mutable { f(); })); } @@ -274,7 +274,7 @@ public: const Future<T>& onDiscarded(F&& f) const { return onDiscarded(std::function<void()>( - [=] () mutable { + [=]() mutable { f(); })); } @@ -725,7 +725,7 @@ Future<Future<T>> select(const std::set<Future<T>>& futures) // NOTE: We can't use std::bind with a std::function with Clang // like we do below (see // http://stackoverflow.com/questions/20097616/stdbind-to-a-stdfunction-crashes-with-clang). - (*iterator).onAny([=] (const Future<T>& future) { + (*iterator).onAny([=](const Future<T>& future) { internal::select(future, promise); }); } http://git-wip-us.apache.org/repos/asf/mesos/blob/765b6c8e/3rdparty/libprocess/src/io.cpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/src/io.cpp b/3rdparty/libprocess/src/io.cpp index 5f1d27b..4944e28 100644 --- a/3rdparty/libprocess/src/io.cpp +++ b/3rdparty/libprocess/src/io.cpp @@ -239,7 +239,7 @@ Future<string> _read( size_t length) { return io::read(fd, data.get(), length) - .then([=] (size_t size) -> Future<string> { + .then([=](size_t size) -> Future<string> { if (size == 0) { // EOF. return string(*buffer); } @@ -255,7 +255,7 @@ Future<Nothing> _write( size_t index) { return io::write(fd, (void*) (data->data() + index), data->size() - index) - .then([=] (size_t length) -> Future<Nothing> { + .then([=](size_t length) -> Future<Nothing> { if (index + length == data->size()) { return Nothing(); } @@ -292,7 +292,7 @@ void _splice( WeakFuture<size_t>(read))); read - .onReady([=] (size_t size) { + .onReady([=](size_t size) { if (size == 0) { // EOF. promise->set(Nothing()); } else { @@ -301,13 +301,13 @@ void _splice( // semantics where everything read is written. The promise // will eventually be discarded in the next read. io::write(to, string(data.get(), size)) - .onReady([=] () { _splice(from, to, chunk, data, promise); }) - .onFailed([=] (const string& message) { promise->fail(message); }) - .onDiscarded([=] () { promise->discard(); }); + .onReady([=]() { _splice(from, to, chunk, data, promise); }) + .onFailed([=](const string& message) { promise->fail(message); }) + .onDiscarded([=]() { promise->discard(); }); } }) - .onFailed([=] (const string& message) { promise->fail(message); }) - .onDiscarded([=] () { promise->discard(); }); + .onFailed([=](const string& message) { promise->fail(message); }) + .onDiscarded([=]() { promise->discard(); }); } http://git-wip-us.apache.org/repos/asf/mesos/blob/765b6c8e/3rdparty/libprocess/src/tests/process_tests.cpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/src/tests/process_tests.cpp b/3rdparty/libprocess/src/tests/process_tests.cpp index b6c6c51..67e582c 100644 --- a/3rdparty/libprocess/src/tests/process_tests.cpp +++ b/3rdparty/libprocess/src/tests/process_tests.cpp @@ -711,12 +711,12 @@ TEST(Process, defer3) volatile bool bool2 = false; Deferred<void(bool)> set1 = - defer([&bool1] (bool b) { bool1 = b; }); + defer([&bool1](bool b) { bool1 = b; }); set1(true); Deferred<void(bool)> set2 = - defer([&bool2] (bool b) { bool2 = b; }); + defer([&bool2](bool b) { bool2 = b; }); set2(true); @@ -1702,34 +1702,34 @@ TEST(Process, defers) std::bind(bam, std::placeholders::_1)); std::function<Future<int>(string)> f2 = - defer([] (string s) { return baz(s); }); + defer([](string s) { return baz(s); }); Deferred<Future<int>(string)> d2 = - defer([] (string s) { return baz(s); }); + defer([](string s) { return baz(s); }); Future<int> future2 = Future<string>().then( - defer([] (string s) { return baz(s); })); + defer([](string s) { return baz(s); })); Future<int> future4 = Future<string>().then( - [] (string s) { return baz(s); }); + [](string s) { return baz(s); }); Future<int> future5 = Future<string>().then( - defer([] (string s) -> Future<int> { return baz(s); })); + defer([](string s) -> Future<int> { return baz(s); })); Future<int> future6 = Future<string>().then( - defer([] (string s) { return Future<int>(baz(s)); })); + defer([](string s) { return Future<int>(baz(s)); })); Future<int> future7 = Future<string>().then( - defer([] (string s) { return bam(s); })); + defer([](string s) { return bam(s); })); Future<int> future8 = Future<string>().then( - [] (string s) { return Future<int>(baz(s)); }); + [](string s) { return Future<int>(baz(s)); }); Future<int> future9 = Future<string>().then( - [] (string s) -> Future<int> { return baz(s); }); + [](string s) -> Future<int> { return baz(s); }); Future<int> future10 = Future<string>().then( - [] (string s) { return bam(s); }); + [](string s) { return bam(s); }); } // { @@ -1741,7 +1741,7 @@ TEST(Process, defers) // std::function<void(string)> blam = blah; // std::function<void(string)> f2 = -// defer([] (string s) { return baz(s); }); +// defer([](string s) { return baz(s); }); // } // { @@ -1755,7 +1755,7 @@ TEST(Process, defers) defer(std::bind(baz, "42")); std::function<Future<int>(void)> f2 = - defer([] () { return baz("42"); }); + defer([]() { return baz("42"); }); } { @@ -1763,7 +1763,7 @@ TEST(Process, defers) defer(std::bind(baz, "42")); std::function<Future<int>(int)> f2 = - defer([] (int i) { return baz("42"); }); + defer([](int i) { return baz("42"); }); } // Don't care about value passed from Future::then. @@ -1781,28 +1781,28 @@ TEST(Process, defers) std::bind(bam, "42")); Future<int> future2 = Future<string>().then( - defer([] () { return baz("42"); })); + defer([]() { return baz("42"); })); Future<int> future4 = Future<string>().then( - [] () { return baz("42"); }); + []() { return baz("42"); }); Future<int> future5 = Future<string>().then( - defer([] () -> Future<int> { return baz("42"); })); + defer([]() -> Future<int> { return baz("42"); })); Future<int> future6 = Future<string>().then( - defer([] () { return Future<int>(baz("42")); })); + defer([]() { return Future<int>(baz("42")); })); Future<int> future7 = Future<string>().then( - defer([] () { return bam("42"); })); + defer([]() { return bam("42"); })); Future<int> future8 = Future<string>().then( - [] () { return Future<int>(baz("42")); }); + []() { return Future<int>(baz("42")); }); Future<int> future9 = Future<string>().then( - [] () -> Future<int> { return baz("42"); }); + []() -> Future<int> { return baz("42"); }); Future<int> future10 = Future<string>().then( - [] () { return bam("42"); }); + []() { return bam("42"); }); } struct Functor
