Commit 3fb62b36 authored by Hans Fugal's avatar Hans Fugal Committed by Dave Watson

(wangle) more comment tweaks

Test Plan: eyeballs

Reviewed By: hannesr@fb.com

FB internal diff: D1185813
parent 07b986bf
...@@ -21,6 +21,11 @@ ...@@ -21,6 +21,11 @@
namespace folly { namespace wangle { namespace folly { namespace wangle {
/// This generic threadgate takes two executors and an optional waiter (if you
/// need to support waiting). Hint: use executors that inherit from Executor
/// (in Executor.h), then you just do
///
/// GenericThreadGate tg(westExecutor, eastExecutor, waiter);
template < template <
class WestExecutorPtr = Executor*, class WestExecutorPtr = Executor*,
class EastExecutorPtr = Executor*, class EastExecutorPtr = Executor*,
...@@ -52,6 +57,7 @@ public: ...@@ -52,6 +57,7 @@ public:
WestExecutorPtr westExecutor; WestExecutorPtr westExecutor;
EastExecutorPtr eastExecutor; EastExecutorPtr eastExecutor;
WaiterPtr waiter; WaiterPtr waiter;
private: private:
void makeProgress_(std::true_type const&) { void makeProgress_(std::true_type const&) {
throw std::logic_error("No waiter."); throw std::logic_error("No waiter.");
......
...@@ -110,18 +110,18 @@ class Later { ...@@ -110,18 +110,18 @@ class Later {
/* /*
* Resets the executor - all then() calls made after the call to via() will be * Resets the executor - all then() calls made after the call to via() will be
* made in the new executor. * made in the new executor. The Executor must outlive.
*/ */
Later<T> via(Executor* executor); Later<T> via(Executor* executor);
/* /*
* Starts the workflow. The function provided in the constructor will be * Starts the workflow. The function provided in the constructor will be
* called in the executor provided in the constructor. All proximate then() * called in the executor provided in the constructor. Subsequent then()
* calls will be made, potentially changing threads if a via() call is made. * calls will be made, potentially changing threads if a via() call is made.
* The future returned will be fulfilled in the last executor. * The future returned will be fulfilled in the last executor.
* *
* Thread safety issues of Futures still apply. If you want to wait on the * Thread safety issues of Futures still apply. If you want to wait on the
* Future, it must be done in the thread that will fulfill it. If you do not * Future, it must be done in the thread that will fulfil it. If you do not
* plan to use the result of the Future, use fireAndForget() * plan to use the result of the Future, use fireAndForget()
*/ */
Future<T> launch(); Future<T> launch();
......
...@@ -49,9 +49,7 @@ namespace folly { namespace wangle { ...@@ -49,9 +49,7 @@ namespace folly { namespace wangle {
In order to make and use a ThreadGate, you need to provide a strategy for In order to make and use a ThreadGate, you need to provide a strategy for
executing code in the east and west threads. These strategies may be executing code in the east and west threads. These strategies may be
different. The only requirement is a threadsafe method different. The only requirement is a threadsafe method
`void add(function<void()>&&)`. You may find the executors in `void add(function<void()>&&)`.
Executor.h handy, but ensure that you are using them
threadsafely.
In order for your ThreadGate to do anything, you need to drive those In order for your ThreadGate to do anything, you need to drive those
executors somehow. An event loop is a natural fit. A thread pool might be executors somehow. An event loop is a natural fit. A thread pool might be
...@@ -69,6 +67,9 @@ namespace folly { namespace wangle { ...@@ -69,6 +67,9 @@ namespace folly { namespace wangle {
Future change toward a multithreaded architecture easier, as you need only Future change toward a multithreaded architecture easier, as you need only
change the components of the ThreadGate which your client code is already change the components of the ThreadGate which your client code is already
using. using.
Later (in Later.h) is an alternative mechanism for thread-traversing
asynchronous workflows.
*/ */
class ThreadGate { class ThreadGate {
public: public:
......
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