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/02/05 19:59:13 UTC
[2/5] git commit: Refactored io::write for C++03.
Refactored io::write for C++03.
Review: https://reviews.apache.org/r/17619
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/61ec7026
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/61ec7026
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/61ec7026
Branch: refs/heads/master
Commit: 61ec7026523fde25d9c403f42e89e83dde9d62df
Parents: 659a91f
Author: Benjamin Hindman <be...@gmail.com>
Authored: Fri Jan 31 13:14:31 2014 -0800
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Wed Feb 5 10:58:36 2014 -0800
----------------------------------------------------------------------
3rdparty/libprocess/src/process.cpp | 42 ++++++++++++++++++++++++++------
1 file changed, 35 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/61ec7026/3rdparty/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp
index 27765fa..bc111c6 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -3702,8 +3702,7 @@ Future<string> _read(
Future<string> __read(
- const size_t& size,
- // TODO(benh): Remove 'const &' after fixing libprocess.
+ size_t size,
int fd,
const memory::shared_ptr<string>& buffer,
const boost::shared_array<char>& data,
@@ -3745,6 +3744,35 @@ Future<Nothing> _write(
return _write(fd, data, index + length);
});
}
+#else
+// Forward declaration.
+Future<Nothing> _write(
+ int fd,
+ Owned<string> data,
+ size_t index);
+
+
+Future<Nothing> __write(
+ int fd,
+ Owned<string> data,
+ size_t index,
+ size_t length)
+{
+ if (index + length == data->size()) {
+ return Nothing();
+ }
+ return _write(fd, data, index + length);
+}
+
+
+Future<Nothing> _write(
+ int fd,
+ Owned<string> data,
+ size_t index)
+{
+ return io::write(fd, (void*) (data->data() + index), data->size() - index)
+ .then(lambda::bind(&__write, fd, data, index, lambda::_1));
+}
#endif // __cplusplus >= 201103L
} // namespace internal
@@ -3875,12 +3903,12 @@ Future<Response> request(
return Failure("Failed to set nonblock: " + nonblock.error());
}
+ // Need to disambiguate the io::read we want when binding below.
+ Future<string> (*read)(int) = io::read;
+
return io::write(s, out.str())
- .then([=] () {
- // Decode once the async read completes.
- return io::read(s)
- .then(lambda::bind(&internal::decode, lambda::_1));
- })
+ .then(lambda::bind(read, s))
+ .then(lambda::bind(&internal::decode, lambda::_1))
.onAny(lambda::bind(&os::close, s));
}