You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2014/01/14 21:04:55 UTC
[04/15] git commit: Replaced 'std::tr1' with 'lambda' and 'memory' in
stout.
Replaced 'std::tr1' with 'lambda' and 'memory' in stout.
The 'lambda' and 'memory' namespace gives us a level-of-indirection
that makes it easier to do either C++03 or C++11 compilation.
Review: https://reviews.apache.org/r/16654
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/7f16f83d
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/7f16f83d
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/7f16f83d
Branch: refs/heads/master
Commit: 7f16f83dce0292ba10873f7953de30b05caa2407
Parents: 7810f9e
Author: Benjamin Hindman <be...@gmail.com>
Authored: Sun Dec 29 21:59:48 2013 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Mon Jan 13 23:48:23 2014 -0800
----------------------------------------------------------------------
3rdparty/libprocess/3rdparty/stout/Makefile.am | 1 +
.../3rdparty/stout/include/stout/cache.hpp | 5 +-
.../3rdparty/stout/include/stout/flags/flag.hpp | 7 ++-
.../stout/include/stout/flags/flags.hpp | 51 ++++++++++----------
.../stout/include/stout/flags/loader.hpp | 11 ++---
.../stout/include/stout/flags/parse.hpp | 2 -
.../stout/include/stout/flags/stringifier.hpp | 2 -
.../3rdparty/stout/include/stout/format.hpp | 4 ++
.../3rdparty/stout/include/stout/lambda.hpp | 13 +++--
.../3rdparty/stout/include/stout/memory.hpp | 17 +++++++
.../3rdparty/stout/include/stout/os/fork.hpp | 7 ++-
11 files changed, 70 insertions(+), 50 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/7f16f83d/3rdparty/libprocess/3rdparty/stout/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/Makefile.am b/3rdparty/libprocess/3rdparty/stout/Makefile.am
index 9e7a4a8..0725722 100644
--- a/3rdparty/libprocess/3rdparty/stout/Makefile.am
+++ b/3rdparty/libprocess/3rdparty/stout/Makefile.am
@@ -28,6 +28,7 @@ EXTRA_DIST = \
include/stout/json.hpp \
include/stout/lambda.hpp \
include/stout/linkedhashmap.hpp \
+ include/stout/memory.hpp \
include/stout/multihashmap.hpp \
include/stout/multimap.hpp \
include/stout/net.hpp \
http://git-wip-us.apache.org/repos/asf/mesos/blob/7f16f83d/3rdparty/libprocess/3rdparty/stout/include/stout/cache.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/cache.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/cache.hpp
index 653507c..443bedf 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/cache.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/cache.hpp
@@ -6,8 +6,7 @@
#include <list>
#include <map>
-#include <tr1/functional>
-#include <tr1/unordered_map>
+#include <boost/unordered_map.hpp>
#include "none.hpp"
#include "option.hpp"
@@ -30,7 +29,7 @@ class cache
{
public:
typedef std::list<Key> list;
- typedef std::tr1::unordered_map<
+ typedef boost::unordered_map<
Key, std::pair<Value, typename list::iterator> > map;
explicit cache(int _capacity) : capacity(_capacity) {}
http://git-wip-us.apache.org/repos/asf/mesos/blob/7f16f83d/3rdparty/libprocess/3rdparty/stout/include/stout/flags/flag.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/flags/flag.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/flags/flag.hpp
index 2ba739d..14135ca 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/flags/flag.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/flags/flag.hpp
@@ -3,8 +3,7 @@
#include <string>
-#include <tr1/functional>
-
+#include <stout/lambda.hpp>
#include <stout/nothing.hpp>
#include <stout/try.hpp>
@@ -18,8 +17,8 @@ struct Flag
std::string name;
std::string help;
bool boolean;
- std::tr1::function<Try<Nothing>(FlagsBase*, const std::string&)> loader;
- std::tr1::function<Option<std::string>(const FlagsBase&)> stringify;
+ lambda::function<Try<Nothing>(FlagsBase*, const std::string&)> loader;
+ lambda::function<Option<std::string>(const FlagsBase&)> stringify;
};
} // namespace flags {
http://git-wip-us.apache.org/repos/asf/mesos/blob/7f16f83d/3rdparty/libprocess/3rdparty/stout/include/stout/flags/flags.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/flags/flags.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/flags/flags.hpp
index 0d3c836..32d5aae 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/flags/flags.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/flags/flags.hpp
@@ -7,11 +7,10 @@
#include <string>
#include <typeinfo> // For typeid.
-#include <tr1/functional>
-
#include <stout/error.hpp>
#include <stout/exit.hpp>
#include <stout/foreach.hpp>
+#include <stout/lambda.hpp>
#include <stout/none.hpp>
#include <stout/nothing.hpp>
#include <stout/option.hpp>
@@ -149,14 +148,14 @@ void FlagsBase::add(
flag.name = name;
flag.help = help;
flag.boolean = typeid(T1) == typeid(bool);
- flag.loader = std::tr1::bind(
+ flag.loader = lambda::bind(
&Loader<T1>::load,
t1,
- std::tr1::function<Try<T1>(const std::string&)>(
- std::tr1::bind(&parse<T1>, std::tr1::placeholders::_1)),
+ lambda::function<Try<T1>(const std::string&)>(
+ lambda::bind(&parse<T1>, lambda::_1)),
name,
- std::tr1::placeholders::_2); // Use _2 because ignore FlagsBase*.
- flag.stringify = std::tr1::bind(&Stringifier<T1>, t1);
+ lambda::_2); // Use _2 because ignore FlagsBase*.
+ flag.stringify = lambda::bind(&Stringifier<T1>, t1);
// Update the help string to include the default value.
flag.help += help.size() > 0 && help.find_last_of("\n\r") != help.size() - 1
@@ -179,14 +178,14 @@ void FlagsBase::add(
flag.name = name;
flag.help = help;
flag.boolean = typeid(T) == typeid(bool);
- flag.loader = std::tr1::bind(
+ flag.loader = lambda::bind(
&OptionLoader<T>::load,
option,
- std::tr1::function<Try<T>(const std::string&)>(
- std::tr1::bind(&parse<T>, std::tr1::placeholders::_1)),
+ lambda::function<Try<T>(const std::string&)>(
+ lambda::bind(&parse<T>, lambda::_1)),
name,
- std::tr1::placeholders::_2); // Use _2 because ignore FlagsBase*.
- flag.stringify = std::tr1::bind(&OptionStringifier<T>, option);
+ lambda::_2); // Use _2 because ignore FlagsBase*.
+ flag.stringify = lambda::bind(&OptionStringifier<T>, option);
FlagsBase::add(flag);
}
@@ -212,17 +211,17 @@ void FlagsBase::add(
flag.name = name;
flag.help = help;
flag.boolean = typeid(T1) == typeid(bool);
- flag.loader = std::tr1::bind(
+ flag.loader = lambda::bind(
&MemberLoader<Flags, T1>::load,
- std::tr1::placeholders::_1,
+ lambda::_1,
t1,
- std::tr1::function<Try<T1>(const std::string&)>(
- std::tr1::bind(&parse<T1>, std::tr1::placeholders::_1)),
+ lambda::function<Try<T1>(const std::string&)>(
+ lambda::bind(&parse<T1>, lambda::_1)),
name,
- std::tr1::placeholders::_2);
- flag.stringify = std::tr1::bind(
+ lambda::_2);
+ flag.stringify = lambda::bind(
&MemberStringifier<Flags, T1>,
- std::tr1::placeholders::_1,
+ lambda::_1,
t1);
// Update the help string to include the default value.
@@ -253,17 +252,17 @@ void FlagsBase::add(
flag.name = name;
flag.help = help;
flag.boolean = typeid(T) == typeid(bool);
- flag.loader = std::tr1::bind(
+ flag.loader = lambda::bind(
&OptionMemberLoader<Flags, T>::load,
- std::tr1::placeholders::_1,
+ lambda::_1,
option,
- std::tr1::function<Try<T>(const std::string&)>(
- std::tr1::bind(&parse<T>, std::tr1::placeholders::_1)),
+ lambda::function<Try<T>(const std::string&)>(
+ lambda::bind(&parse<T>, lambda::_1)),
name,
- std::tr1::placeholders::_2);
- flag.stringify = std::tr1::bind(
+ lambda::_2);
+ flag.stringify = lambda::bind(
&OptionMemberStringifier<Flags, T>,
- std::tr1::placeholders::_1,
+ lambda::_1,
option);
add(flag);
http://git-wip-us.apache.org/repos/asf/mesos/blob/7f16f83d/3rdparty/libprocess/3rdparty/stout/include/stout/flags/loader.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/flags/loader.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/flags/loader.hpp
index a6e0f58..f2e0eae 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/flags/loader.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/flags/loader.hpp
@@ -3,9 +3,8 @@
#include <string>
-#include <tr1/functional>
-
#include <stout/error.hpp>
+#include <stout/lambda.hpp>
#include <stout/nothing.hpp>
#include <stout/option.hpp>
#include <stout/some.hpp>
@@ -23,7 +22,7 @@ struct Loader
{
static Try<Nothing> load(
T* flag,
- const std::tr1::function<Try<T>(const std::string&)>& parse,
+ const lambda::function<Try<T>(const std::string&)>& parse,
const std::string& name,
const std::string& value)
{
@@ -43,7 +42,7 @@ struct OptionLoader
{
static Try<Nothing> load(
Option<T>* flag,
- const std::tr1::function<Try<T>(const std::string&)>& parse,
+ const lambda::function<Try<T>(const std::string&)>& parse,
const std::string& name,
const std::string& value)
{
@@ -64,7 +63,7 @@ struct MemberLoader
static Try<Nothing> load(
FlagsBase* base,
T F::*flag,
- const std::tr1::function<Try<T>(const std::string&)>& parse,
+ const lambda::function<Try<T>(const std::string&)>& parse,
const std::string& name,
const std::string& value)
{
@@ -88,7 +87,7 @@ struct OptionMemberLoader
static Try<Nothing> load(
FlagsBase* base,
Option<T> F::*flag,
- const std::tr1::function<Try<T>(const std::string&)>& parse,
+ const lambda::function<Try<T>(const std::string&)>& parse,
const std::string& name,
const std::string& value)
{
http://git-wip-us.apache.org/repos/asf/mesos/blob/7f16f83d/3rdparty/libprocess/3rdparty/stout/include/stout/flags/parse.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/flags/parse.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/flags/parse.hpp
index 4c5b297..bfa7b9c 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/flags/parse.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/flags/parse.hpp
@@ -4,8 +4,6 @@
#include <sstream> // For istringstream.
#include <string>
-#include <tr1/functional>
-
#include <stout/duration.hpp>
#include <stout/error.hpp>
#include <stout/try.hpp>
http://git-wip-us.apache.org/repos/asf/mesos/blob/7f16f83d/3rdparty/libprocess/3rdparty/stout/include/stout/flags/stringifier.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/flags/stringifier.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/flags/stringifier.hpp
index 669218c..204c17e 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/flags/stringifier.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/flags/stringifier.hpp
@@ -3,8 +3,6 @@
#include <string>
-#include <tr1/functional>
-
#include <stout/error.hpp>
#include <stout/nothing.hpp>
#include <stout/option.hpp>
http://git-wip-us.apache.org/repos/asf/mesos/blob/7f16f83d/3rdparty/libprocess/3rdparty/stout/include/stout/format.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/format.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/format.hpp
index cae7fcb..c7623e7 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/format.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/format.hpp
@@ -6,7 +6,11 @@
#include <string>
+#if __cplusplus >= 201103L
+#include <type_traits> // For 'is_pod'.
+#else // __cplusplus >= 201103L
#include <tr1/type_traits> // For 'is_pod'.
+#endif // __cplusplus >= 201103L
#include "error.hpp"
#include "try.hpp"
http://git-wip-us.apache.org/repos/asf/mesos/blob/7f16f83d/3rdparty/libprocess/3rdparty/stout/include/stout/lambda.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/lambda.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/lambda.hpp
index d493353..67b241d 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/lambda.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/lambda.hpp
@@ -1,14 +1,21 @@
#ifndef __STOUT_LAMBDA_HPP__
#define __STOUT_LAMBDA_HPP__
+#if __cplusplus >= 201103L
+namespace lambda {
+using std::bind;
+using std::function;
+using std::result_of;
+using namespace std::placeholders;
+} // namespace lambda {
+#else // __cplusplus >= 201103L
#include <tr1/functional>
-
namespace lambda {
-
using std::tr1::bind;
using std::tr1::function;
+using std::tr1::result_of;
using namespace std::tr1::placeholders;
-
} // namespace lambda {
+#endif // __cplusplus >= 201103L
#endif // __STOUT_LAMBDA_HPP__
http://git-wip-us.apache.org/repos/asf/mesos/blob/7f16f83d/3rdparty/libprocess/3rdparty/stout/include/stout/memory.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/memory.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/memory.hpp
new file mode 100644
index 0000000..6e7ee43
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/memory.hpp
@@ -0,0 +1,17 @@
+#ifndef __STOUT_MEMORY_HPP__
+#define __STOUT_MEMORY_HPP__
+
+#if __cplusplus >= 201103L
+namespace memory {
+using std::shared_ptr;
+using std::weak_ptr;
+} // namespace memory {
+#else // __cplusplus >= 201103L
+#include <tr1/memory>
+namespace memory {
+using std::tr1::shared_ptr;
+using std::tr1::weak_ptr;
+} // namespace memory {
+#endif // __cplusplus >= 201103L
+
+#endif // __STOUT_MEMORY_HPP__
http://git-wip-us.apache.org/repos/asf/mesos/blob/7f16f83d/3rdparty/libprocess/3rdparty/stout/include/stout/os/fork.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/fork.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/fork.hpp
index 838a5fe..72e4c1f 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os/fork.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/fork.hpp
@@ -12,11 +12,10 @@
#include <set>
#include <string>
-#include <tr1/memory>
-
#include <stout/error.hpp>
#include <stout/exit.hpp>
#include <stout/foreach.hpp>
+#include <stout/memory.hpp>
#include <stout/option.hpp>
#include <stout/os.hpp>
#include <stout/stringify.hpp>
@@ -220,7 +219,7 @@ private:
bool set; // Has this been initialized?
};
- std::tr1::shared_ptr<Memory> memory;
+ memory::shared_ptr<Memory> memory;
std::vector<Tree> children;
};
@@ -297,7 +296,7 @@ private:
SharedMemoryDeleter deleter(fd);
Tree tree;
- tree.memory = std::tr1::shared_ptr<Tree::Memory>(
+ tree.memory = memory::shared_ptr<Tree::Memory>(
(Tree::Memory*) memory, deleter);
tree.memory->set = false;