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 2012/09/18 00:26:59 UTC

svn commit: r1386881 - in /incubator/mesos/trunk/third_party/libprocess/src: statistics_tests.cpp tests.cpp

Author: benh
Date: Mon Sep 17 22:26:59 2012
New Revision: 1386881

URL: http://svn.apache.org/viewvc?rev=1386881&view=rev
Log:
Added an 'async' function execution abstraction (contributed by Vinod
Kone, https://reviews.apache.org/r/6668).

Modified:
    incubator/mesos/trunk/third_party/libprocess/src/statistics_tests.cpp
    incubator/mesos/trunk/third_party/libprocess/src/tests.cpp

Modified: incubator/mesos/trunk/third_party/libprocess/src/statistics_tests.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/src/statistics_tests.cpp?rev=1386881&r1=1386880&r2=1386881&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/src/statistics_tests.cpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/src/statistics_tests.cpp Mon Sep 17 22:26:59 2012
@@ -1,21 +1,3 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
 #include <gmock/gmock.h>
 
 #include <map>

Modified: incubator/mesos/trunk/third_party/libprocess/src/tests.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/src/tests.cpp?rev=1386881&r1=1386880&r2=1386881&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/src/tests.cpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/src/tests.cpp Mon Sep 17 22:26:59 2012
@@ -8,6 +8,7 @@
 #include <string>
 #include <sstream>
 
+#include <process/async.hpp>
 #include <process/collect.hpp>
 #include <process/clock.hpp>
 #include <process/defer.hpp>
@@ -1227,6 +1228,61 @@ TEST(Process, read)
 }
 
 
+int foo()
+{
+  return 1;
+}
+
+int foo1(int a)
+{
+  return a;
+}
+
+
+int foo2(int a, int b)
+{
+  return a + b;
+}
+
+
+int foo3(int a, int b, int c)
+{
+  return a + b + c;
+}
+
+
+int foo4(int a, int b, int c, int d)
+{
+  return a + b + c + d;
+}
+
+
+void bar(int a)
+{
+  return;
+}
+
+
+TEST(Process, async)
+{
+  ASSERT_TRUE(GTEST_IS_THREADSAFE);
+
+  // Non-void functions with different no.of args.
+  EXPECT_EQ(1, async(&foo).get());
+  EXPECT_EQ(10, async(&foo1, 10).get());
+  EXPECT_EQ(30, async(&foo2, 10, 20).get());
+  EXPECT_EQ(60, async(&foo3, 10, 20, 30).get());
+  EXPECT_EQ(100, async(&foo4, 10, 20, 30, 40).get());
+
+  // Non-void function with a complex arg.
+  int i = 42;
+  EXPECT_EQ("42", async(&itoa2, &i).get());
+
+  // Non-void function that returns a future.
+  EXPECT_EQ("42", async(&itoa1, &i).get().get());
+}
+
+
 int main(int argc, char** argv)
 {
   // Initialize Google Mock/Test.