Repository: mesos Updated Branches: refs/heads/master d46c0d7eb -> b26a2e1a7
Update some existing lambdas to meet style guide. Review: https://reviews.apache.org/r/34018 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b26a2e1a Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b26a2e1a Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b26a2e1a Branch: refs/heads/master Commit: b26a2e1a716fdc775c301fab15f3fa991b070867 Parents: d46c0d7 Author: haosdent huang <[email protected]> Authored: Mon May 18 14:20:39 2015 -0700 Committer: Benjamin Hindman <[email protected]> Committed: Mon May 18 14:24:27 2015 -0700 ---------------------------------------------------------------------- src/linux/cgroups.cpp | 5 +---- src/log/network.hpp | 17 +++++++---------- .../containerizer/isolators/cgroups/cpushare.cpp | 13 ++++--------- src/slave/containerizer/isolators/cgroups/mem.cpp | 8 +++----- .../isolators/network/port_mapping.cpp | 5 +---- src/slave/containerizer/mesos/containerizer.cpp | 14 ++------------ 6 files changed, 18 insertions(+), 44 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/b26a2e1a/src/linux/cgroups.cpp ---------------------------------------------------------------------- diff --git a/src/linux/cgroups.cpp b/src/linux/cgroups.cpp index df3211a..831237b 100644 --- a/src/linux/cgroups.cpp +++ b/src/linux/cgroups.cpp @@ -2151,13 +2151,10 @@ Try<Bytes> max_usage_in_bytes(const string& hierarchy, const string& cgroup) namespace oom { -static Nothing _nothing() { return Nothing(); } - - Future<Nothing> listen(const string& hierarchy, const string& cgroup) { return cgroups::event::listen(hierarchy, cgroup, "memory.oom_control") - .then(lambda::bind(&_nothing)); + .then([]() { return Nothing(); }); } http://git-wip-us.apache.org/repos/asf/mesos/blob/b26a2e1a/src/log/network.hpp ---------------------------------------------------------------------- diff --git a/src/log/network.hpp b/src/log/network.hpp index 7c74a55..ff3496b 100644 --- a/src/log/network.hpp +++ b/src/log/network.hpp @@ -119,15 +119,6 @@ public: private: typedef ZooKeeperNetwork This; - // Helper for handling time outs when collecting membership - // data. For now, a timeout is treated as a failure. - static process::Future<std::list<Option<std::string> > > timedout( - process::Future<std::list<Option<std::string> > > datas) - { - datas.discard(); - return process::Failure("Timed out"); - } - // Not copyable, not assignable. ZooKeeperNetwork(const ZooKeeperNetwork&); ZooKeeperNetwork& operator = (const ZooKeeperNetwork&); @@ -431,7 +422,13 @@ inline void ZooKeeperNetwork::watched( } process::collect(futures) - .after(Seconds(5), lambda::bind(&This::timedout, lambda::_1)) + .after(Seconds(5), + [](process::Future<std::list<Option<std::string>>> datas) { + // Handling time outs when collecting membership + // data. For now, a timeout is treated as a failure. + datas.discard(); + return process::Failure("Timed out"); + }) .onAny(executor.defer(lambda::bind(&This::collected, this, lambda::_1))); } http://git-wip-us.apache.org/repos/asf/mesos/blob/b26a2e1a/src/slave/containerizer/isolators/cgroups/cpushare.cpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/isolators/cgroups/cpushare.cpp b/src/slave/containerizer/isolators/cgroups/cpushare.cpp index 6a5b2b5..e3b5e2a 100644 --- a/src/slave/containerizer/isolators/cgroups/cpushare.cpp +++ b/src/slave/containerizer/isolators/cgroups/cpushare.cpp @@ -61,13 +61,6 @@ namespace mesos { namespace internal { namespace slave { -template<class T> -static Future<Option<T>> none() { return None(); } - - -static Future<Nothing> _nothing() { return Nothing(); } - - CgroupsCpushareIsolatorProcess::CgroupsCpushareIsolatorProcess( const Flags& _flags, const hashmap<string, string>& _hierarchies, @@ -304,7 +297,9 @@ Future<Option<CommandInfo>> CgroupsCpushareIsolatorProcess::prepare( } return update(containerId, executorInfo.resources()) - .then(lambda::bind(none<CommandInfo>)); + .then([]() -> Future<Option<CommandInfo>> { + return None(); + }); } @@ -540,7 +535,7 @@ Future<Nothing> CgroupsCpushareIsolatorProcess::cleanup( &CgroupsCpushareIsolatorProcess::_cleanup, containerId, lambda::_1)) - .then(lambda::bind(&_nothing)); + .then([]() { return Nothing(); }); } http://git-wip-us.apache.org/repos/asf/mesos/blob/b26a2e1a/src/slave/containerizer/isolators/cgroups/mem.cpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/isolators/cgroups/mem.cpp b/src/slave/containerizer/isolators/cgroups/mem.cpp index 2c218b2..d3b77d4 100644 --- a/src/slave/containerizer/isolators/cgroups/mem.cpp +++ b/src/slave/containerizer/isolators/cgroups/mem.cpp @@ -64,10 +64,6 @@ namespace mesos { namespace internal { namespace slave { -template<class T> -static Future<Option<T>> none() { return None(); } - - static const vector<Level> levels() { return {Level::LOW, Level::MEDIUM, Level::CRITICAL}; @@ -286,7 +282,9 @@ Future<Option<CommandInfo>> CgroupsMemIsolatorProcess::prepare( pressureListen(containerId); return update(containerId, executorInfo.resources()) - .then(lambda::bind(none<CommandInfo>)); + .then([]() -> Future<Option<CommandInfo>> { + return None(); + }); } http://git-wip-us.apache.org/repos/asf/mesos/blob/b26a2e1a/src/slave/containerizer/isolators/network/port_mapping.cpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/isolators/network/port_mapping.cpp b/src/slave/containerizer/isolators/network/port_mapping.cpp index a4abaff..49e983e 100644 --- a/src/slave/containerizer/isolators/network/port_mapping.cpp +++ b/src/slave/containerizer/isolators/network/port_mapping.cpp @@ -142,9 +142,6 @@ static Interval<uint16_t> WELL_KNOWN_PORTS() // Helper functions for the isolator. ///////////////////////////////////////////////// -static Future<Nothing> _nothing() { return Nothing(); } - - // Given an integer x, find the largest integer t such that t <= x and // t is aligned to power of 2. static uint32_t roundDownToPowerOfTwo(uint32_t x) @@ -2317,7 +2314,7 @@ Future<Nothing> PortMappingIsolatorProcess::update( &PortMappingIsolatorProcess::_update, containerId, lambda::_1)) - .then(lambda::bind(&_nothing)); + .then([]() { return Nothing(); }); } http://git-wip-us.apache.org/repos/asf/mesos/blob/b26a2e1a/src/slave/containerizer/mesos/containerizer.cpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/mesos/containerizer.cpp b/src/slave/containerizer/mesos/containerizer.cpp index b644b9c..696e359 100644 --- a/src/slave/containerizer/mesos/containerizer.cpp +++ b/src/slave/containerizer/mesos/containerizer.cpp @@ -82,10 +82,6 @@ using state::FrameworkState; using state::ExecutorState; using state::RunState; -// Local function declaration/definitions. -static Future<Nothing> _nothing() { return Nothing(); } - - Try<MesosContainerizer*> MesosContainerizer::create( const Flags& flags, bool local, @@ -794,12 +790,6 @@ Future<bool> MesosContainerizerProcess::_launch( } -static Future<bool> _isolate() -{ - return true; -} - - Future<bool> MesosContainerizerProcess::isolate( const ContainerID& containerId, pid_t _pid) @@ -828,7 +818,7 @@ Future<bool> MesosContainerizerProcess::isolate( containers_[containerId]->isolation = future; - return future.then(lambda::bind(&_isolate)); + return future.then([]() { return true; }); } @@ -912,7 +902,7 @@ Future<Nothing> MesosContainerizerProcess::update( // Wait for all isolators to complete. return collect(futures) - .then(lambda::bind(&_nothing)); + .then([]() { return Nothing(); }); }
