move futures/DrivableExecutor to executors/DrivableExecutor
authorJames Sedgwick <jsedgwick@fb.com>
Wed, 18 Oct 2017 16:44:09 +0000 (09:44 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 18 Oct 2017 16:51:38 +0000 (09:51 -0700)
Summary: as title

Reviewed By: yfeldblum

Differential Revision: D6062437

fbshipit-source-id: 4f99e779e280fdb0b1f035013caff18764e86ab5

folly/Makefile.am
folly/executors/DrivableExecutor.h [new file with mode: 0644]
folly/executors/NotificationQueueExecutor.h
folly/futures/DrivableExecutor.h [deleted file]
folly/futures/Future.h
folly/futures/ManualExecutor.h
folly/futures/README.md
folly/futures/test/ViaTest.cpp
folly/io/async/EventBase.h

index 94b417c27dbd2a6a23d02beab6bca159921ed83e..7159baeaf0067ad4cf182a88b032ddb17df92cd7 100644 (file)
@@ -88,6 +88,7 @@ nobase_follyinclude_HEADERS = \
        executors/BlockingQueue.h \
        executors/CPUThreadPoolExecutor.h \
        executors/Codel.h \
+       executors/DrivableExecutor.h \
        executors/FiberIOExecutor.h \
        executors/FutureExecutor.h \
        executors/GlobalExecutor.h \
@@ -205,7 +206,6 @@ nobase_follyinclude_HEADERS = \
        Format-inl.h \
        functional/Invoke.h \
        futures/Barrier.h \
-       futures/DrivableExecutor.h \
        futures/Future-pre.h \
        futures/helpers.h \
        futures/Future.h \
diff --git a/folly/executors/DrivableExecutor.h b/folly/executors/DrivableExecutor.h
new file mode 100644 (file)
index 0000000..9f9b61e
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2017 Facebook, Inc.
+ *
+ * Licensed 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.
+ */
+
+#pragma once
+
+#include <folly/Executor.h>
+
+namespace folly {
+
+/*
+ * A DrivableExecutor can be driven via its drive() method
+ * Examples include EventBase (via loopOnce()) and ManualExecutor
+ * (via makeProgress()).
+ *
+ * This interface is most handy in conjunction with
+ * Future<T>::getVia(DrivableExecutor*) and
+ * Future<T>::waitVia(DrivableExecutor*)
+ *
+ * These call drive() * repeatedly until the Future is fulfilled.
+ * getVia() returns the value (or throws the exception) and waitVia() returns
+ * the same Future for chainability.
+ *
+ * These will be most helpful in tests, for instance if you need to pump a mock
+ * EventBase until Futures complete.
+ */
+
+class DrivableExecutor : public virtual Executor {
+ public:
+  ~DrivableExecutor() override = default;
+
+  // Make progress on this Executor's work.
+  //
+  // Drive *must not* busy wait if there is no work to do.  Instead,
+  // sleep (using a semaphore or similar) until at least one event is
+  // processed.
+  // I.e. make_future().via(foo).then(...).getVia(DrivableExecutor)
+  // must not spin, even though nothing happens on the drivable
+  // executor.
+  virtual void drive() = 0;
+};
+
+} // namespace folly
index 3738be24e71a166d41d8836a8a51903c9f7c74f5..5e19fc41c66bb06ed14fbd6f5c038dc708a057e4 100644 (file)
@@ -17,7 +17,7 @@
 
 #include <folly/ExceptionString.h>
 #include <folly/Function.h>
-#include <folly/futures/DrivableExecutor.h>
+#include <folly/executors/DrivableExecutor.h>
 #include <folly/io/async/NotificationQueue.h>
 
 namespace folly {
diff --git a/folly/futures/DrivableExecutor.h b/folly/futures/DrivableExecutor.h
deleted file mode 100644 (file)
index 9f9b61e..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2017 Facebook, Inc.
- *
- * Licensed 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.
- */
-
-#pragma once
-
-#include <folly/Executor.h>
-
-namespace folly {
-
-/*
- * A DrivableExecutor can be driven via its drive() method
- * Examples include EventBase (via loopOnce()) and ManualExecutor
- * (via makeProgress()).
- *
- * This interface is most handy in conjunction with
- * Future<T>::getVia(DrivableExecutor*) and
- * Future<T>::waitVia(DrivableExecutor*)
- *
- * These call drive() * repeatedly until the Future is fulfilled.
- * getVia() returns the value (or throws the exception) and waitVia() returns
- * the same Future for chainability.
- *
- * These will be most helpful in tests, for instance if you need to pump a mock
- * EventBase until Futures complete.
- */
-
-class DrivableExecutor : public virtual Executor {
- public:
-  ~DrivableExecutor() override = default;
-
-  // Make progress on this Executor's work.
-  //
-  // Drive *must not* busy wait if there is no work to do.  Instead,
-  // sleep (using a semaphore or similar) until at least one event is
-  // processed.
-  // I.e. make_future().via(foo).then(...).getVia(DrivableExecutor)
-  // must not spin, even though nothing happens on the drivable
-  // executor.
-  virtual void drive() = 0;
-};
-
-} // namespace folly
index f5c3190f91ca9da03256037a59dacb8880ee08a6..0c4092aa241810b7ccee79010c13614fe3a070c5 100644 (file)
@@ -27,7 +27,7 @@
 #include <folly/Portability.h>
 #include <folly/Try.h>
 #include <folly/Utility.h>
-#include <folly/futures/DrivableExecutor.h>
+#include <folly/executors/DrivableExecutor.h>
 #include <folly/futures/FutureException.h>
 #include <folly/futures/Promise.h>
 #include <folly/futures/detail/Types.h>
index 689111eb62acf685dea5612c469b085b189790fd..373e4ac731613d00c85bbddc435396a23e1e9161 100644 (file)
@@ -22,7 +22,7 @@
 #include <queue>
 
 #include <folly/LifoSem.h>
-#include <folly/futures/DrivableExecutor.h>
+#include <folly/executors/DrivableExecutor.h>
 #include <folly/futures/ScheduledExecutor.h>
 
 namespace folly {
index d0e2693df2a4156975e037de61eefc5b11299328..e4bce6797f75990670a007db1d75838ebfc499f3 100644 (file)
@@ -902,7 +902,7 @@ Although inspired by the C++11 std::future interface, it is not a drop-in replac
 
 <h3 id="getvia-and-waitvia">getVia() and waitVia() <a href="#getvia-and-waitvia" class="headerLink">#</a></h3>
 
-<p><tt>T Future&lt;T&gt;::getVia(DrivableExecutor*)</tt> and <tt>Future&lt;T&gt; Future&lt;T&gt;::waitVia(DrivableExecutor*)</tt> have the same semantics as <tt>get()</tt> and <tt>wait()</tt> except that they drive some Executor until the Future is complete. <a href="https://github.com/facebook/folly/blob/master/folly/futures/DrivableExecutor.h" target="_blank"><tt>DrivableExecutor</tt></a> is a simple subinterface of <tt>Executor</tt> that requires the presence of a method <tt>drive()</tt> which can somehow make progress on the Executor&#039;s work. Two commonly helpful implementations are <a href="https://github.com/facebook/folly/blob/master/folly/io/async/EventBase.h" target="_blank"><tt>EventBase</tt></a> (where <tt>drive()</tt> loops on the EventBase) and <a href="https://github.com/facebook/folly/blob/master/folly/futures/ManualExecutor.h" target="_blank"><tt>ManualExecutor</tt></a>. These are simple but useful sugar for the following common pattern:</p>
+<p><tt>T Future&lt;T&gt;::getVia(DrivableExecutor*)</tt> and <tt>Future&lt;T&gt; Future&lt;T&gt;::waitVia(DrivableExecutor*)</tt> have the same semantics as <tt>get()</tt> and <tt>wait()</tt> except that they drive some Executor until the Future is complete. <a href="https://github.com/facebook/folly/blob/master/folly/executors/DrivableExecutor.h" target="_blank"><tt>DrivableExecutor</tt></a> is a simple subinterface of <tt>Executor</tt> that requires the presence of a method <tt>drive()</tt> which can somehow make progress on the Executor&#039;s work. Two commonly helpful implementations are <a href="https://github.com/facebook/folly/blob/master/folly/io/async/EventBase.h" target="_blank"><tt>EventBase</tt></a> (where <tt>drive()</tt> loops on the EventBase) and <a href="https://github.com/facebook/folly/blob/master/folly/futures/ManualExecutor.h" target="_blank"><tt>ManualExecutor</tt></a>. These are simple but useful sugar for the following common pattern:</p>
 
 <p>Given this:</p>
 
index 198c4f93048899436ff2386dfbcc52d682a0a4ab..1a530d37706aa2f651751cc9ed1c9833131a519e 100644 (file)
@@ -18,7 +18,7 @@
 
 #include <folly/Baton.h>
 #include <folly/MPMCQueue.h>
-#include <folly/futures/DrivableExecutor.h>
+#include <folly/executors/DrivableExecutor.h>
 #include <folly/futures/Future.h>
 #include <folly/futures/InlineExecutor.h>
 #include <folly/futures/ManualExecutor.h>
index ee7ceca7d06c7fa9d0ee782c3bae8f198ec3e05e..670d6af65167950e378d78880156b0dd798743d5 100644 (file)
 #include <folly/Function.h>
 #include <folly/Portability.h>
 #include <folly/ScopeGuard.h>
+#include <folly/executors/DrivableExecutor.h>
 #include <folly/experimental/ExecutionObserver.h>
-#include <folly/futures/DrivableExecutor.h>
 #include <folly/io/async/AsyncTimeout.h>
 #include <folly/io/async/HHWheelTimer.h>
 #include <folly/io/async/Request.h>
 #include <folly/io/async/TimeoutManager.h>
 #include <folly/portability/Event.h>
 
-
 namespace folly {
 
 using Cob = Func; // defined in folly/Executor.h