Commit 502c8e4b authored by James Sedgwick's avatar James Sedgwick Committed by Viswanath Sivakumar

move Futures from folly::wangle to folly

Summary: Namespace change. Next up is to extract the Executors into folly/executors/

Test Plan: wait for contbuild

Reviewed By: davejwatson@fb.com

Subscribers: jsedgwick, trunkagent, fbcode-common-diffs@, chaoyc, search-fbcode-diffs@, lars, davejwatson, ruibalp, hero-diffs@, zeus-diffs@, andrewcox, vikas, mcduff, cold-storage-diffs@, unicorn-diffs@, ldbrandy, targeting-diff-backend@, netego-diffs@, abirchall, fugalh, adamsyta, atlas2-eng@, chenzhimin, mpawlowski, alandau, bmatheny, adityab, everstore-dev@, zhuohuang, mwa, jgehring, prometheus-diffs@, smarlow, akr, bnitka, jcoens, benj, laser-diffs@, zhguo, jying, darshan, micha, apodsiadlo, alikhtarov, fuegen, dzhulgakov, jeremyfein, mshneer, folly-diffs@, wch, lins, tingy, hannesr, maxwellsayles

FB internal diff: D1772779

Tasks: 5960242

Signature: t1:1772779:1420751149:bc0b9220be25f1d46d9cef3fdeaa9c3681217aff
parent f3ac5cca
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <folly/futures/detail/Core.h> #include <folly/futures/detail/Core.h>
#include <folly/futures/Timekeeper.h> #include <folly/futures/Timekeeper.h>
namespace folly { namespace wangle { namespace folly {
class Timekeeper; class Timekeeper;
...@@ -724,7 +724,7 @@ namespace { ...@@ -724,7 +724,7 @@ namespace {
auto token = std::make_shared<std::atomic<bool>>(); auto token = std::make_shared<std::atomic<bool>>();
folly::Baton<> baton; folly::Baton<> baton;
folly::wangle::detail::getTimekeeperSingleton()->after(dur) folly::detail::getTimekeeperSingleton()->after(dur)
.then([&,token](Try<void> const& t) { .then([&,token](Try<void> const& t) {
if (token->exchange(true) == false) { if (token->exchange(true) == false) {
try { try {
...@@ -797,7 +797,7 @@ Future<T> Future<T>::within(Duration dur, E e, Timekeeper* tk) { ...@@ -797,7 +797,7 @@ Future<T> Future<T>::within(Duration dur, E e, Timekeeper* tk) {
auto ctx = std::make_shared<Context>(std::move(e)); auto ctx = std::make_shared<Context>(std::move(e));
if (!tk) { if (!tk) {
tk = folly::wangle::detail::getTimekeeperSingleton(); tk = folly::detail::getTimekeeperSingleton();
} }
tk->after(dur) tk->after(dur)
...@@ -834,7 +834,7 @@ Future<T> Future<T>::delayed(Duration dur, Timekeeper* tk) { ...@@ -834,7 +834,7 @@ Future<T> Future<T>::delayed(Duration dur, Timekeeper* tk) {
}); });
} }
}} }
// I haven't included a Future<T&> specialization because I don't forsee us // I haven't included a Future<T&> specialization because I don't forsee us
// using it, however it is not difficult to add when needed. Refer to // using it, however it is not difficult to add when needed. Refer to
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include <folly/futures/detail/ThreadWheelTimekeeper.h> #include <folly/futures/detail/ThreadWheelTimekeeper.h>
#include <folly/Likely.h> #include <folly/Likely.h>
namespace folly { namespace wangle { namespace futures { namespace folly { namespace futures {
Future<void> sleep(Duration dur, Timekeeper* tk) { Future<void> sleep(Duration dur, Timekeeper* tk) {
if (LIKELY(!tk)) { if (LIKELY(!tk)) {
...@@ -26,4 +26,4 @@ Future<void> sleep(Duration dur, Timekeeper* tk) { ...@@ -26,4 +26,4 @@ Future<void> sleep(Duration dur, Timekeeper* tk) {
return tk->after(dur); return tk->after(dur);
} }
}}} }}
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include <folly/futures/WangleException.h> #include <folly/futures/WangleException.h>
#include <folly/futures/detail/Types.h> #include <folly/futures/detail/Types.h>
namespace folly { namespace wangle { namespace folly {
template <class> struct Promise; template <class> struct Promise;
...@@ -626,6 +626,6 @@ Future<T> waitWithSemaphore(Future<T>&& f); ...@@ -626,6 +626,6 @@ Future<T> waitWithSemaphore(Future<T>&& f);
template <typename T, class Dur> template <typename T, class Dur>
Future<T> waitWithSemaphore(Future<T>&& f, Dur timeout); Future<T> waitWithSemaphore(Future<T>&& f, Dur timeout);
}} // folly::wangle } // folly
#include <folly/futures/Future-inl.h> #include <folly/futures/Future-inl.h>
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#pragma once #pragma once
#include <folly/Executor.h> #include <folly/Executor.h>
namespace folly { namespace wangle { namespace folly {
/// When work is "queued", execute it immediately inline. /// When work is "queued", execute it immediately inline.
/// Usually when you think you want this, you actually want a /// Usually when you think you want this, you actually want a
...@@ -29,4 +29,4 @@ namespace folly { namespace wangle { ...@@ -29,4 +29,4 @@ namespace folly { namespace wangle {
} }
}; };
}} }
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <stdexcept> #include <stdexcept>
namespace folly { namespace wangle { namespace folly {
ManualExecutor::ManualExecutor() { ManualExecutor::ManualExecutor() {
if (sem_init(&sem_, 0, 0) == -1) { if (sem_init(&sem_, 0, 0) == -1) {
...@@ -101,4 +101,4 @@ void ManualExecutor::advanceTo(TimePoint const& t) { ...@@ -101,4 +101,4 @@ void ManualExecutor::advanceTo(TimePoint const& t) {
run(); run();
} }
}} // namespace } // folly
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <queue> #include <queue>
#include <cstdio> #include <cstdio>
namespace folly { namespace wangle { namespace folly {
/// A ManualExecutor only does work when you turn the crank, by calling /// A ManualExecutor only does work when you turn the crank, by calling
/// run() or indirectly with makeProgress() or waitFor(). /// run() or indirectly with makeProgress() or waitFor().
/// ///
...@@ -117,4 +117,4 @@ namespace folly { namespace wangle { ...@@ -117,4 +117,4 @@ namespace folly { namespace wangle {
TimePoint now_ = now_.min(); TimePoint now_ = now_.min();
}; };
}} }
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include <folly/futures/Promise.h> #include <folly/futures/Promise.h>
namespace folly { namespace wangle { namespace folly {
/// These classes help you wrap an existing C style callback function /// These classes help you wrap an existing C style callback function
/// into a Future. /// into a Future.
...@@ -49,9 +49,9 @@ public: ...@@ -49,9 +49,9 @@ public:
static_cast<OpaqueCallbackShunt<T>*>(arg)); static_cast<OpaqueCallbackShunt<T>*>(arg));
handle->promise_.setValue(std::move(handle->obj_)); handle->promise_.setValue(std::move(handle->obj_));
} }
folly::wangle::Promise<T> promise_; folly::Promise<T> promise_;
private: private:
T obj_; T obj_;
}; };
}} // folly::wangle } // folly
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <folly/futures/WangleException.h> #include <folly/futures/WangleException.h>
#include <folly/futures/detail/Core.h> #include <folly/futures/detail/Core.h>
namespace folly { namespace wangle { namespace folly {
template <class T> template <class T>
Promise<T>::Promise() : retrieved_(false), core_(new detail::Core<T>()) Promise<T>::Promise() : retrieved_(false), core_(new detail::Core<T>())
...@@ -136,4 +136,4 @@ void Promise<T>::fulfil(F&& func) { ...@@ -136,4 +136,4 @@ void Promise<T>::fulfil(F&& func) {
fulfilTry(makeTryFunction(std::forward<F>(func))); fulfilTry(makeTryFunction(std::forward<F>(func)));
} }
}} }
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <folly/futures/Try.h> #include <folly/futures/Try.h>
#include <functional> #include <functional>
namespace folly { namespace wangle { namespace folly {
// forward declaration // forward declaration
template <class T> class Future; template <class T> class Future;
...@@ -102,7 +102,7 @@ private: ...@@ -102,7 +102,7 @@ private:
void detach(); void detach();
}; };
}} }
#include <folly/futures/Future.h> #include <folly/futures/Future.h>
#include <folly/futures/Promise-inl.h> #include <folly/futures/Promise-inl.h>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include <folly/ThreadLocal.h> #include <folly/ThreadLocal.h>
#include <queue> #include <queue>
namespace folly { namespace wangle { namespace folly {
void QueuedImmediateExecutor::add(Func callback) { void QueuedImmediateExecutor::add(Func callback) {
thread_local std::queue<Func> q; thread_local std::queue<Func> q;
...@@ -34,4 +34,4 @@ void QueuedImmediateExecutor::add(Func callback) { ...@@ -34,4 +34,4 @@ void QueuedImmediateExecutor::add(Func callback) {
} }
} }
}} // namespace } // namespace
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include <folly/Executor.h> #include <folly/Executor.h>
namespace folly { namespace wangle { namespace folly {
/** /**
* Runs inline like InlineExecutor, but with a queue so that any tasks added * Runs inline like InlineExecutor, but with a queue so that any tasks added
...@@ -30,4 +30,4 @@ class QueuedImmediateExecutor : public Executor { ...@@ -30,4 +30,4 @@ class QueuedImmediateExecutor : public Executor {
void add(Func) override; void add(Func) override;
}; };
}} // namespace } // folly
...@@ -19,7 +19,7 @@ The primary semantic differences are that Wangle Futures and Promises are not th ...@@ -19,7 +19,7 @@ The primary semantic differences are that Wangle Futures and Promises are not th
```C++ ```C++
#include <folly/futures/Future.h> #include <folly/futures/Future.h>
using namespace folly::wangle; using namespace folly;
using namespace std; using namespace std;
void foo(int x) { void foo(int x) {
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include <memory> #include <memory>
#include <stdexcept> #include <stdexcept>
namespace folly { namespace wangle { namespace folly {
// An executor that supports timed scheduling. Like RxScheduler. // An executor that supports timed scheduling. Like RxScheduler.
class ScheduledExecutor : public Executor { class ScheduledExecutor : public Executor {
public: public:
...@@ -54,4 +54,4 @@ namespace folly { namespace wangle { ...@@ -54,4 +54,4 @@ namespace folly { namespace wangle {
return std::chrono::steady_clock::now(); return std::chrono::steady_clock::now();
} }
}; };
}} }
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include <folly/futures/detail/Types.h> #include <folly/futures/detail/Types.h>
namespace folly { namespace wangle { namespace folly {
template <class> struct Future; template <class> struct Future;
...@@ -68,16 +68,16 @@ class Timekeeper { ...@@ -68,16 +68,16 @@ class Timekeeper {
Future<void> at(std::chrono::time_point<Clock> when); Future<void> at(std::chrono::time_point<Clock> when);
}; };
}} } // namespace folly
// now get those definitions // now get those definitions
#include <folly/futures/Future.h> #include <folly/futures/Future.h>
// finally we can use Future // finally we can use Future
namespace folly { namespace wangle { namespace folly {
template <class Clock> template <class Clock>
Future<void> Timekeeper::at(std::chrono::time_point<Clock> when) { Future<void> Timekeeper::at(std::chrono::time_point<Clock> when) {
auto now = Clock::now(); auto now = Clock::now();
if (when <= now) { if (when <= now) {
...@@ -85,6 +85,6 @@ namespace folly { namespace wangle { ...@@ -85,6 +85,6 @@ namespace folly { namespace wangle {
} }
return after(when - now); return after(when - now);
} }
}} } // namespace folly
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <folly/futures/WangleException.h> #include <folly/futures/WangleException.h>
namespace folly { namespace wangle { namespace folly {
template <class T> template <class T>
Try<T>::Try(Try<T>&& t) : contains_(t.contains_) { Try<T>::Try(Try<T>&& t) : contains_(t.contains_) {
...@@ -82,11 +82,11 @@ void Try<void>::throwIfFailed() const { ...@@ -82,11 +82,11 @@ void Try<void>::throwIfFailed() const {
} }
template <typename T> template <typename T>
inline T moveFromTry(wangle::Try<T>&& t) { inline T moveFromTry(Try<T>&& t) {
return std::move(t.value()); return std::move(t.value());
} }
inline void moveFromTry(wangle::Try<void>&& t) { inline void moveFromTry(Try<void>&& t) {
return t.value(); return t.value();
} }
...@@ -120,4 +120,4 @@ makeTryFunction(F&& f) { ...@@ -120,4 +120,4 @@ makeTryFunction(F&& f) {
} }
} }
}} } // folly
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <folly/futures/Deprecated.h> #include <folly/futures/Deprecated.h>
#include <folly/futures/WangleException.h> #include <folly/futures/WangleException.h>
namespace folly { namespace wangle { namespace folly {
/* /*
* Try<T> is a wrapper that contains either an instance of T, an exception, or * Try<T> is a wrapper that contains either an instance of T, an exception, or
...@@ -313,14 +313,14 @@ class Try<void> { ...@@ -313,14 +313,14 @@ class Try<void> {
* @returns value contained in t * @returns value contained in t
*/ */
template <typename T> template <typename T>
T moveFromTry(wangle::Try<T>&& t); T moveFromTry(Try<T>&& t);
/* /*
* Throws if try contained an exception. * Throws if try contained an exception.
* *
* @param t Try to move from * @param t Try to move from
*/ */
void moveFromTry(wangle::Try<void>&& t); void moveFromTry(Try<void>&& t);
/* /*
* @param f a function to execute and capture the result of (value or exception) * @param f a function to execute and capture the result of (value or exception)
...@@ -346,7 +346,6 @@ typename std::enable_if< ...@@ -346,7 +346,6 @@ typename std::enable_if<
Try<void>>::type Try<void>>::type
makeTryFunction(F&& f); makeTryFunction(F&& f);
} // folly
}}
#include <folly/futures/Try-inl.h> #include <folly/futures/Try-inl.h>
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include <exception> #include <exception>
#include <string> #include <string>
namespace folly { namespace wangle { namespace folly {
class WangleException : public std::exception { class WangleException : public std::exception {
...@@ -91,4 +91,4 @@ class TimedOut : public WangleException { ...@@ -91,4 +91,4 @@ class TimedOut : public WangleException {
TimedOut() : WangleException("Timed out") {} TimedOut() : WangleException("Timed out") {}
}; };
}} }
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include <folly/io/async/Request.h> #include <folly/io/async/Request.h>
namespace folly { namespace wangle { namespace detail { namespace folly { namespace detail {
// As of GCC 4.8.1, the std::function in libstdc++ optimizes only for pointers // As of GCC 4.8.1, the std::function in libstdc++ optimizes only for pointers
// to functions, using a helper avoids a call to malloc. // to functions, using a helper avoids a call to malloc.
...@@ -289,4 +289,4 @@ struct WhenAnyContext { ...@@ -289,4 +289,4 @@ struct WhenAnyContext {
} }
}; };
}}} // namespace }} // folly::detail
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <mutex> #include <mutex>
#include <folly/SmallLocks.h> #include <folly/SmallLocks.h>
namespace folly { namespace wangle { namespace detail { namespace folly { namespace detail {
/// Finite State Machine helper base class. /// Finite State Machine helper base class.
/// Inherit from this. /// Inherit from this.
...@@ -119,4 +119,4 @@ public: ...@@ -119,4 +119,4 @@ public:
#define FSM_END }}} #define FSM_END }}}
}}} }} // folly::detail
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include <folly/futures/Future.h> #include <folly/futures/Future.h>
#include <future> #include <future>
namespace folly { namespace wangle { namespace detail { namespace folly { namespace detail {
namespace { namespace {
Singleton<ThreadWheelTimekeeper> timekeeperSingleton_; Singleton<ThreadWheelTimekeeper> timekeeperSingleton_;
...@@ -90,4 +90,4 @@ Timekeeper* getTimekeeperSingleton() { ...@@ -90,4 +90,4 @@ Timekeeper* getTimekeeperSingleton() {
return timekeeperSingleton_.get_fast(); return timekeeperSingleton_.get_fast();
} }
}}} }} // folly::detail
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <folly/io/async/HHWheelTimer.h> #include <folly/io/async/HHWheelTimer.h>
#include <thread> #include <thread>
namespace folly { namespace wangle { namespace detail { namespace folly { namespace detail {
/// The default Timekeeper implementation which uses a HHWheelTimer on an /// The default Timekeeper implementation which uses a HHWheelTimer on an
/// EventBase in a dedicated thread. Users needn't deal with this directly, it /// EventBase in a dedicated thread. Users needn't deal with this directly, it
...@@ -47,4 +47,4 @@ class ThreadWheelTimekeeper : public Timekeeper { ...@@ -47,4 +47,4 @@ class ThreadWheelTimekeeper : public Timekeeper {
Timekeeper* getTimekeeperSingleton(); Timekeeper* getTimekeeperSingleton();
}}} }} // folly::detail
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
#include <chrono> #include <chrono>
namespace folly { namespace wangle { namespace folly {
using Duration = std::chrono::milliseconds; using Duration = std::chrono::milliseconds;
}} }
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <semaphore.h> #include <semaphore.h>
#include <vector> #include <vector>
using namespace folly::wangle; using namespace folly;
using namespace std; using namespace std;
namespace { namespace {
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include <folly/futures/Future.h> #include <folly/futures/Future.h>
#include <folly/Baton.h> #include <folly/Baton.h>
using namespace folly::wangle; using namespace folly;
using namespace std::chrono; using namespace std::chrono;
using namespace testing; using namespace testing;
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <folly/futures/detail/FSM.h> #include <folly/futures/detail/FSM.h>
using namespace folly::wangle::detail; using namespace folly::detail;
enum class State { A, B }; enum class State { A, B };
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include <folly/io/async/Request.h> #include <folly/io/async/Request.h>
using namespace folly; using namespace folly;
using namespace folly::wangle;
using std::pair; using std::pair;
using std::string; using std::string;
using std::unique_ptr; using std::unique_ptr;
...@@ -1187,7 +1186,7 @@ TEST(Future, CircularDependencySharedPtrSelfReset) { ...@@ -1187,7 +1186,7 @@ TEST(Future, CircularDependencySharedPtrSelfReset) {
auto ptr = std::make_shared<Future<int64_t>>(promise.getFuture()); auto ptr = std::make_shared<Future<int64_t>>(promise.getFuture());
ptr->then( ptr->then(
[ptr] (folly::wangle::Try<int64_t>&& uid) mutable { [ptr] (folly::Try<int64_t>&& uid) mutable {
EXPECT_EQ(1, ptr.use_count()); EXPECT_EQ(1, ptr.use_count());
// Leaving no references to ourselves. // Leaving no references to ourselves.
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include <folly/futures/Future.h> #include <folly/futures/Future.h>
#include <folly/futures/Promise.h> #include <folly/futures/Promise.h>
using namespace folly::wangle; using namespace folly;
using folly::exception_wrapper; using folly::exception_wrapper;
TEST(Interrupts, raise) { TEST(Interrupts, raise) {
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <folly/futures/Future.h> #include <folly/futures/Future.h>
#include <folly/Executor.h> #include <folly/Executor.h>
using namespace folly::wangle; using namespace folly;
using namespace std; using namespace std;
using namespace testing; using namespace testing;
......
...@@ -18,10 +18,10 @@ ...@@ -18,10 +18,10 @@
#include <folly/futures/Timekeeper.h> #include <folly/futures/Timekeeper.h>
#include <unistd.h> #include <unistd.h>
using namespace folly::wangle; using namespace folly;
using namespace std::chrono; using namespace std::chrono;
using folly::wangle::Timekeeper; using folly::Timekeeper;
using Duration = folly::wangle::Duration; using Duration = folly::Duration;
std::chrono::milliseconds const one_ms(1); std::chrono::milliseconds const one_ms(1);
std::chrono::milliseconds const awhile(10); std::chrono::milliseconds const awhile(10);
...@@ -32,7 +32,7 @@ std::chrono::steady_clock::time_point now() { ...@@ -32,7 +32,7 @@ std::chrono::steady_clock::time_point now() {
struct TimekeeperFixture : public testing::Test { struct TimekeeperFixture : public testing::Test {
TimekeeperFixture() : TimekeeperFixture() :
timeLord_(folly::wangle::detail::getTimekeeperSingleton()) timeLord_(folly::detail::getTimekeeperSingleton())
{} {}
Timekeeper* timeLord_; Timekeeper* timeLord_;
...@@ -71,7 +71,7 @@ TEST(Timekeeper, futureGetBeforeTimeout) { ...@@ -71,7 +71,7 @@ TEST(Timekeeper, futureGetBeforeTimeout) {
TEST(Timekeeper, futureGetTimeout) { TEST(Timekeeper, futureGetTimeout) {
Promise<int> p; Promise<int> p;
EXPECT_THROW(p.getFuture().get(Duration(1)), folly::wangle::TimedOut); EXPECT_THROW(p.getFuture().get(Duration(1)), folly::TimedOut);
} }
TEST(Timekeeper, futureSleep) { TEST(Timekeeper, futureSleep) {
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include <folly/Memory.h> #include <folly/Memory.h>
#include <folly/futures/Try.h> #include <folly/futures/Try.h>
using namespace folly::wangle; using namespace folly;
TEST(Try, makeTryFunction) { TEST(Try, makeTryFunction) {
auto func = []() { auto func = []() {
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include <folly/futures/InlineExecutor.h> #include <folly/futures/InlineExecutor.h>
#include <folly/futures/ManualExecutor.h> #include <folly/futures/ManualExecutor.h>
using namespace folly::wangle; using namespace folly;
struct ManualWaiter { struct ManualWaiter {
explicit ManualWaiter(std::shared_ptr<ManualExecutor> ex) : ex(ex) {} explicit ManualWaiter(std::shared_ptr<ManualExecutor> ex) : ex(ex) {}
......
...@@ -281,7 +281,7 @@ threads. Major uses for this include: ...@@ -281,7 +281,7 @@ threads. Major uses for this include:
In this library only runInEventBaseThread save/restores the request In this library only runInEventBaseThread save/restores the request
context, although other Facebook libraries that pass requests between context, although other Facebook libraries that pass requests between
threads do also: folly::wangle::future, and fbthrift::ThreadManager, etc threads do also: folly::future, and fbthrift::ThreadManager, etc
### DelayedDestruction ### DelayedDestruction
......
...@@ -69,16 +69,16 @@ class AsyncSocketHandler ...@@ -69,16 +69,16 @@ class AsyncSocketHandler
ctx_ = ctx; ctx_ = ctx;
} }
folly::wangle::Future<void> write( folly::Future<void> write(
Context* ctx, Context* ctx,
std::unique_ptr<folly::IOBuf> buf) override { std::unique_ptr<folly::IOBuf> buf) override {
if (UNLIKELY(!buf)) { if (UNLIKELY(!buf)) {
return folly::wangle::makeFuture(); return folly::makeFuture();
} }
if (!socket_->good()) { if (!socket_->good()) {
VLOG(5) << "socket is closed in write()"; VLOG(5) << "socket is closed in write()";
return folly::wangle::makeFuture<void>(AsyncSocketException( return folly::makeFuture<void>(AsyncSocketException(
AsyncSocketException::AsyncSocketExceptionType::NOT_OPEN, AsyncSocketException::AsyncSocketExceptionType::NOT_OPEN,
"socket is closed in write()")); "socket is closed in write()"));
} }
...@@ -89,12 +89,12 @@ class AsyncSocketHandler ...@@ -89,12 +89,12 @@ class AsyncSocketHandler
return future; return future;
}; };
folly::wangle::Future<void> close(Context* ctx) { folly::Future<void> close(Context* ctx) {
if (socket_) { if (socket_) {
detachReadCallback(); detachReadCallback();
socket_->closeNow(); socket_->closeNow();
} }
return folly::wangle::makeFuture(); return folly::makeFuture();
} }
// Must override to avoid warnings about hidden overloaded virtual due to // Must override to avoid warnings about hidden overloaded virtual due to
...@@ -142,7 +142,7 @@ class AsyncSocketHandler ...@@ -142,7 +142,7 @@ class AsyncSocketHandler
private: private:
friend class AsyncSocketHandler; friend class AsyncSocketHandler;
folly::wangle::Promise<void> promise_; folly::Promise<void> promise_;
}; };
Context* ctx_{nullptr}; Context* ctx_{nullptr};
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <glog/logging.h> #include <glog/logging.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
using namespace folly;
using namespace folly::wangle; using namespace folly::wangle;
using namespace std::chrono; using namespace std::chrono;
......
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