From a56a988a8cd07c7e3250f27594b8f92c9274b30d Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Thu, 19 May 2016 02:20:24 -0700 Subject: [PATCH] Extract Try to top-level Summary: [Folly] Extract `Try` to top-level. It was in `folly/futures/`, but this diff moves it to `folly/`. It is needed for futures, but it is are more general than futures and can be used separately. Use `folly/Try.h` instead of `folly/futures/Try.h`. Also fixes up all `#include` sites: hg grep -lw folly/futures/Try | xargs perl -pi -e 's,\bfolly/futures/Try\b,folly/Try,g' Reviewed By: markisaa Differential Revision: D3309908 fbshipit-source-id: cdf13f0ac0b0e36aa07e0f1d04870d06500c5874 --- folly/Makefile.am | 4 ++-- folly/{futures => }/Try-inl.h | 0 folly/{futures => }/Try.h | 2 +- folly/fibers/AddTasks.h | 2 +- folly/fibers/FiberManager-inl.h | 2 +- folly/fibers/FiberManager.h | 2 +- folly/fibers/Promise.h | 2 +- folly/futures/Future.h | 2 +- folly/futures/Promise.h | 2 +- folly/futures/README.md | 2 +- folly/futures/detail/Core.h | 2 +- folly/futures/test/HeaderCompileTest.cpp | 2 +- folly/test/Makefile.am | 5 ++++- folly/{futures => }/test/TryTest.cpp | 2 +- 14 files changed, 17 insertions(+), 14 deletions(-) rename folly/{futures => }/Try-inl.h (100%) rename folly/{futures => }/Try.h (99%) rename folly/{futures => }/test/TryTest.cpp (98%) diff --git a/folly/Makefile.am b/folly/Makefile.am index 1cc7a2ee..1b28ff7f 100644 --- a/folly/Makefile.am +++ b/folly/Makefile.am @@ -173,8 +173,6 @@ nobase_follyinclude_HEADERS = \ futures/SharedPromise-inl.h \ futures/ThreadWheelTimekeeper.h \ futures/Timekeeper.h \ - futures/Try-inl.h \ - futures/Try.h \ futures/detail/Core.h \ futures/detail/FSM.h \ futures/detail/Types.h \ @@ -345,6 +343,8 @@ nobase_follyinclude_HEADERS = \ ThreadName.h \ TimeoutQueue.h \ Traits.h \ + Try-inl.h \ + Try.h \ Unicode.h \ Function.h \ Unit.h \ diff --git a/folly/futures/Try-inl.h b/folly/Try-inl.h similarity index 100% rename from folly/futures/Try-inl.h rename to folly/Try-inl.h diff --git a/folly/futures/Try.h b/folly/Try.h similarity index 99% rename from folly/futures/Try.h rename to folly/Try.h index ab37a596..edfe6a7e 100644 --- a/folly/futures/Try.h +++ b/folly/Try.h @@ -420,4 +420,4 @@ makeTryWith(F&& f); } // folly -#include +#include diff --git a/folly/fibers/AddTasks.h b/folly/fibers/AddTasks.h index 9e65fcce..63785eaf 100644 --- a/folly/fibers/AddTasks.h +++ b/folly/fibers/AddTasks.h @@ -21,7 +21,7 @@ #include #include #include -#include +#include namespace folly { namespace fibers { diff --git a/folly/fibers/FiberManager-inl.h b/folly/fibers/FiberManager-inl.h index 6b4e94a1..0e14525d 100644 --- a/folly/fibers/FiberManager-inl.h +++ b/folly/fibers/FiberManager-inl.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include namespace folly { namespace fibers { diff --git a/folly/fibers/FiberManager.h b/folly/fibers/FiberManager.h index a617dd6b..a2474b62 100644 --- a/folly/fibers/FiberManager.h +++ b/folly/fibers/FiberManager.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include diff --git a/folly/fibers/Promise.h b/folly/fibers/Promise.h index 807898ef..fde863da 100644 --- a/folly/fibers/Promise.h +++ b/folly/fibers/Promise.h @@ -16,7 +16,7 @@ #pragma once #include -#include +#include namespace folly { namespace fibers { diff --git a/folly/futures/Future.h b/folly/futures/Future.h index 990f2990..c3249fde 100644 --- a/folly/futures/Future.h +++ b/folly/futures/Future.h @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include diff --git a/folly/futures/Promise.h b/folly/futures/Promise.h index 379ad5d6..b18f59b2 100644 --- a/folly/futures/Promise.h +++ b/folly/futures/Promise.h @@ -17,7 +17,7 @@ #pragma once #include -#include +#include #include namespace folly { diff --git a/folly/futures/README.md b/folly/futures/README.md index 1a9e07fd..1af0945d 100644 --- a/folly/futures/README.md +++ b/folly/futures/README.md @@ -259,7 +259,7 @@ Although inspired by the C++11 std::future interface, it is not a drop-in replac

That then() method on futures is the real bread and butter of Futures code. It allows you to provide a callback which will be executed when that Future is complete. Note that while we fulfill the promise after setting the callback here, those operations could be swapped. Setting a callback on an already completed future executes the callback immediately.

-

In this case, the callback takes a value directly. If the Future contained an exception, the callback will be passed over and the exception will be propagated to the resultant Future - more on that in a second. Your callback may also take a Try, which encapsulates either an exception or a value of its templated type.

+

In this case, the callback takes a value directly. If the Future contained an exception, the callback will be passed over and the exception will be propagated to the resultant Future - more on that in a second. Your callback may also take a Try, which encapsulates either an exception or a value of its templated type.

f.then([](Try<int> const& t){
   cout << t.value();
diff --git a/folly/futures/detail/Core.h b/folly/futures/detail/Core.h
index d3dba861..a6ac6109 100644
--- a/folly/futures/detail/Core.h
+++ b/folly/futures/detail/Core.h
@@ -27,7 +27,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 #include 
diff --git a/folly/futures/test/HeaderCompileTest.cpp b/folly/futures/test/HeaderCompileTest.cpp
index cbee3d04..ae2e5ded 100644
--- a/folly/futures/test/HeaderCompileTest.cpp
+++ b/folly/futures/test/HeaderCompileTest.cpp
@@ -18,7 +18,7 @@
 
 // amazing what things can go wrong if you include things in an unexpected
 // order.
-#include 
+#include 
 #include 
 #include 
 
diff --git a/folly/test/Makefile.am b/folly/test/Makefile.am
index 9932fe61..4d000a9a 100644
--- a/folly/test/Makefile.am
+++ b/folly/test/Makefile.am
@@ -215,6 +215,10 @@ indestructible_test_SOURCES = IndestructibleTest.cpp
 indestructible_test_LDADD = libfollytestmain.la
 TESTS += indestructible_test
 
+try_test_SOURCES = TryTest.cpp
+try_test_LDADD = libfollytestmain.la
+TESTS += try_test
+
 unit_test_SOURCES = UnitTest.cpp
 unit_test_LDADD = libfollytestmain.la
 TESTS += unit_test
@@ -244,7 +248,6 @@ futures_test_SOURCES = \
     ../futures/test/ThenTest.cpp \
     ../futures/test/TimekeeperTest.cpp \
     ../futures/test/TimesTest.cpp \
-    ../futures/test/TryTest.cpp \
     ../futures/test/UnwrapTest.cpp \
     ../futures/test/ViaTest.cpp \
     ../futures/test/WaitTest.cpp \
diff --git a/folly/futures/test/TryTest.cpp b/folly/test/TryTest.cpp
similarity index 98%
rename from folly/futures/test/TryTest.cpp
rename to folly/test/TryTest.cpp
index 899db525..e1f2c4e9 100644
--- a/folly/futures/test/TryTest.cpp
+++ b/folly/test/TryTest.cpp
@@ -17,7 +17,7 @@
 #include 
 
 #include 
-#include 
+#include 
 
 using namespace folly;
 
-- 
2.34.1