Repository: mesos
Updated Branches:
  refs/heads/master 087ed2805 -> 5db3fea16


Changed Future::get to return a const reference.

Review: https://reviews.apache.org/r/18443


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/6f066e7f
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/6f066e7f
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/6f066e7f

Branch: refs/heads/master
Commit: 6f066e7ffa976812cd6ed1e9d946411f09337cfc
Parents: 087ed28
Author: Dominic Hamon <[email protected]>
Authored: Tue Mar 4 14:27:55 2014 -0800
Committer: Benjamin Mahler <[email protected]>
Committed: Tue Mar 4 14:37:07 2014 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/future.hpp | 6 ++++--
 3rdparty/libprocess/src/tests/http_tests.cpp   | 6 +++---
 2 files changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/6f066e7f/3rdparty/libprocess/include/process/future.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/future.hpp 
b/3rdparty/libprocess/include/process/future.hpp
index e45f4f7..7c2f755 100644
--- a/3rdparty/libprocess/include/process/future.hpp
+++ b/3rdparty/libprocess/include/process/future.hpp
@@ -128,7 +128,7 @@ public:
 
   // Return the value associated with this future, waits indefinitely
   // until a value gets associated or until the future is discarded.
-  T get() const;
+  const T& get() const;
 
   // Returns the failure message associated with this future.
   std::string failure() const;
@@ -742,6 +742,7 @@ struct unwrap<Future<X> >
 
 inline void acquire(int* lock)
 {
+  // TODO(dhamon): std::atomic when C++11 rolls out.
   while (!__sync_bool_compare_and_swap(lock, 0, 1)) {
     asm volatile ("pause");
   }
@@ -750,6 +751,7 @@ inline void acquire(int* lock)
 
 inline void release(int* lock)
 {
+  // TODO(dhamon): std::atomic when C++11 rolls out.
   // Unlock via a compare-and-swap so we get a memory barrier too.
   bool unlocked = __sync_bool_compare_and_swap(lock, 1, 0);
   assert(unlocked);
@@ -1079,7 +1081,7 @@ bool Future<T>::await(const Duration& duration) const
 
 
 template <typename T>
-T Future<T>::get() const
+const T& Future<T>::get() const
 {
   if (!isReady()) {
     await();

http://git-wip-us.apache.org/repos/asf/mesos/blob/6f066e7f/3rdparty/libprocess/src/tests/http_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/http_tests.cpp 
b/3rdparty/libprocess/src/tests/http_tests.cpp
index 779c30b..983e2a0 100644
--- a/3rdparty/libprocess/src/tests/http_tests.cpp
+++ b/3rdparty/libprocess/src/tests/http_tests.cpp
@@ -113,9 +113,9 @@ TEST(HTTP, Endpoints)
   ASSERT_SOME(os::close(pipes[1]));
 
   AWAIT_READY(future);
-  ASSERT_EQ(http::statuses[200], future.get().status);
-  ASSERT_EQ("chunked", future.get().headers["Transfer-Encoding"]);
-  ASSERT_EQ("Hello World\n", future.get().body);
+  EXPECT_EQ(http::statuses[200], future.get().status);
+  EXPECT_SOME_EQ("chunked", future.get().headers.get("Transfer-Encoding"));
+  EXPECT_EQ("Hello World\n", future.get().body);
 
   terminate(process);
   wait(process);

Reply via email to