Commit a56a988a authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot 6

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
parent 4d78cf49
...@@ -173,8 +173,6 @@ nobase_follyinclude_HEADERS = \ ...@@ -173,8 +173,6 @@ nobase_follyinclude_HEADERS = \
futures/SharedPromise-inl.h \ futures/SharedPromise-inl.h \
futures/ThreadWheelTimekeeper.h \ futures/ThreadWheelTimekeeper.h \
futures/Timekeeper.h \ futures/Timekeeper.h \
futures/Try-inl.h \
futures/Try.h \
futures/detail/Core.h \ futures/detail/Core.h \
futures/detail/FSM.h \ futures/detail/FSM.h \
futures/detail/Types.h \ futures/detail/Types.h \
...@@ -345,6 +343,8 @@ nobase_follyinclude_HEADERS = \ ...@@ -345,6 +343,8 @@ nobase_follyinclude_HEADERS = \
ThreadName.h \ ThreadName.h \
TimeoutQueue.h \ TimeoutQueue.h \
Traits.h \ Traits.h \
Try-inl.h \
Try.h \
Unicode.h \ Unicode.h \
Function.h \ Function.h \
Unit.h \ Unit.h \
......
...@@ -420,4 +420,4 @@ makeTryWith(F&& f); ...@@ -420,4 +420,4 @@ makeTryWith(F&& f);
} // folly } // folly
#include <folly/futures/Try-inl.h> #include <folly/Try-inl.h>
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include <folly/Optional.h> #include <folly/Optional.h>
#include <folly/fibers/FiberManager.h> #include <folly/fibers/FiberManager.h>
#include <folly/fibers/Promise.h> #include <folly/fibers/Promise.h>
#include <folly/futures/Try.h> #include <folly/Try.h>
namespace folly { namespace folly {
namespace fibers { namespace fibers {
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include <folly/fibers/LoopController.h> #include <folly/fibers/LoopController.h>
#include <folly/fibers/Promise.h> #include <folly/fibers/Promise.h>
#include <folly/futures/Promise.h> #include <folly/futures/Promise.h>
#include <folly/futures/Try.h> #include <folly/Try.h>
namespace folly { namespace folly {
namespace fibers { namespace fibers {
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <folly/Executor.h> #include <folly/Executor.h>
#include <folly/IntrusiveList.h> #include <folly/IntrusiveList.h>
#include <folly/Likely.h> #include <folly/Likely.h>
#include <folly/futures/Try.h> #include <folly/Try.h>
#include <folly/io/async/Request.h> #include <folly/io/async/Request.h>
#include <folly/experimental/ExecutionObserver.h> #include <folly/experimental/ExecutionObserver.h>
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#pragma once #pragma once
#include <folly/fibers/traits.h> #include <folly/fibers/traits.h>
#include <folly/futures/Try.h> #include <folly/Try.h>
namespace folly { namespace folly {
namespace fibers { namespace fibers {
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <folly/Portability.h> #include <folly/Portability.h>
#include <folly/futures/DrivableExecutor.h> #include <folly/futures/DrivableExecutor.h>
#include <folly/futures/Promise.h> #include <folly/futures/Promise.h>
#include <folly/futures/Try.h> #include <folly/Try.h>
#include <folly/futures/FutureException.h> #include <folly/futures/FutureException.h>
#include <folly/futures/detail/Types.h> #include <folly/futures/detail/Types.h>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#pragma once #pragma once
#include <folly/Portability.h> #include <folly/Portability.h>
#include <folly/futures/Try.h> #include <folly/Try.h>
#include <functional> #include <functional>
namespace folly { namespace folly {
......
...@@ -259,7 +259,7 @@ Although inspired by the C++11 std::future interface, it is not a drop-in replac ...@@ -259,7 +259,7 @@ Although inspired by the C++11 std::future interface, it is not a drop-in replac
<p>That <tt>then()</tt> 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 <tt>Future</tt> 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.</p> <p>That <tt>then()</tt> 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 <tt>Future</tt> 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.</p>
<p>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 <a href="https://github.com/facebook/folly/blob/master/folly/futures/Try.h" target="_blank">Try</a>, which encapsulates either an exception or a value of its templated type.</p> <p>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 <a href="https://github.com/facebook/folly/blob/master/folly/Try.h" target="_blank">Try</a>, which encapsulates either an exception or a value of its templated type.</p>
<div class="remarkup-code-block" data-code-lang="cpp"><pre class="remarkup-code"><span class=""></span><span class="n">f</span><span class="p">.</span><span class="n">then</span><span class="p">(</span><span class="p">[</span><span class="p">]</span><span class="p">(</span><span class="n">Try</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span><span class=""> </span><span class="k">const</span><span class="o">&amp;</span><span class=""> </span><span class="n">t</span><span class="p">)</span><span class="p">&#123;</span><span class=""> <div class="remarkup-code-block" data-code-lang="cpp"><pre class="remarkup-code"><span class=""></span><span class="n">f</span><span class="p">.</span><span class="n">then</span><span class="p">(</span><span class="p">[</span><span class="p">]</span><span class="p">(</span><span class="n">Try</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span><span class=""> </span><span class="k">const</span><span class="o">&amp;</span><span class=""> </span><span class="n">t</span><span class="p">)</span><span class="p">&#123;</span><span class="">
</span><span class=""> </span><span class="n">cout</span><span class=""> </span><span class="o">&lt;</span><span class="o">&lt;</span><span class=""> </span><span class="n">t</span><span class="p">.</span><span class="n">value</span><span class="p">(</span><span class="p">)</span><span class="p">;</span><span class=""> </span><span class=""> </span><span class="n">cout</span><span class=""> </span><span class="o">&lt;</span><span class="o">&lt;</span><span class=""> </span><span class="n">t</span><span class="p">.</span><span class="n">value</span><span class="p">(</span><span class="p">)</span><span class="p">;</span><span class="">
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <folly/Optional.h> #include <folly/Optional.h>
#include <folly/futures/Future.h> #include <folly/futures/Future.h>
#include <folly/futures/Promise.h> #include <folly/futures/Promise.h>
#include <folly/futures/Try.h> #include <folly/Try.h>
#include <folly/futures/detail/FSM.h> #include <folly/futures/detail/FSM.h>
#include <folly/io/async/Request.h> #include <folly/io/async/Request.h>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// amazing what things can go wrong if you include things in an unexpected // amazing what things can go wrong if you include things in an unexpected
// order. // order.
#include <folly/futures/Try.h> #include <folly/Try.h>
#include <folly/futures/Promise.h> #include <folly/futures/Promise.h>
#include <folly/futures/Future.h> #include <folly/futures/Future.h>
......
...@@ -215,6 +215,10 @@ indestructible_test_SOURCES = IndestructibleTest.cpp ...@@ -215,6 +215,10 @@ indestructible_test_SOURCES = IndestructibleTest.cpp
indestructible_test_LDADD = libfollytestmain.la indestructible_test_LDADD = libfollytestmain.la
TESTS += indestructible_test TESTS += indestructible_test
try_test_SOURCES = TryTest.cpp
try_test_LDADD = libfollytestmain.la
TESTS += try_test
unit_test_SOURCES = UnitTest.cpp unit_test_SOURCES = UnitTest.cpp
unit_test_LDADD = libfollytestmain.la unit_test_LDADD = libfollytestmain.la
TESTS += unit_test TESTS += unit_test
...@@ -244,7 +248,6 @@ futures_test_SOURCES = \ ...@@ -244,7 +248,6 @@ futures_test_SOURCES = \
../futures/test/ThenTest.cpp \ ../futures/test/ThenTest.cpp \
../futures/test/TimekeeperTest.cpp \ ../futures/test/TimekeeperTest.cpp \
../futures/test/TimesTest.cpp \ ../futures/test/TimesTest.cpp \
../futures/test/TryTest.cpp \
../futures/test/UnwrapTest.cpp \ ../futures/test/UnwrapTest.cpp \
../futures/test/ViaTest.cpp \ ../futures/test/ViaTest.cpp \
../futures/test/WaitTest.cpp \ ../futures/test/WaitTest.cpp \
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <folly/Memory.h> #include <folly/Memory.h>
#include <folly/futures/Try.h> #include <folly/Try.h>
using namespace folly; using namespace folly;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment