move futures/ScheduledExecutor to executors/ScheduledExecutor
authorJames Sedgwick <jsedgwick@fb.com>
Wed, 18 Oct 2017 22:01:33 +0000 (15:01 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 18 Oct 2017 22:16:40 +0000 (15:16 -0700)
Summary: see title

Reviewed By: yfeldblum

Differential Revision: D6062601

fbshipit-source-id: edd9a5e85f4ebecd1a6f1004a4d3b8b43b935c2b

folly/Makefile.am
folly/executors/ScheduledExecutor.h [new file with mode: 0644]
folly/futures/ManualExecutor.h
folly/futures/README.md
folly/futures/ScheduledExecutor.h [deleted file]

index bb2d3e1..b9adb7f 100644 (file)
@@ -100,6 +100,7 @@ nobase_follyinclude_HEADERS = \
        executors/NotificationQueueExecutor.h \
        executors/PriorityLifoSemMPMCQueue.h \
        executors/PriorityThreadFactory.h \
+       executors/ScheduledExecutor.h \
        executors/SerialExecutor.h \
        executors/ThreadFactory.h \
        executors/ThreadPoolExecutor.h \
@@ -218,8 +219,6 @@ nobase_follyinclude_HEADERS = \
        futures/Promise-inl.h \
        futures/Promise.h \
        futures/QueuedImmediateExecutor.h \
-       futures/Retrying.h \
-       futures/ScheduledExecutor.h \
        futures/SharedPromise.h \
        futures/SharedPromise-inl.h \
        futures/ThreadWheelTimekeeper.h \
diff --git a/folly/executors/ScheduledExecutor.h b/folly/executors/ScheduledExecutor.h
new file mode 100644 (file)
index 0000000..ac77de9
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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 <chrono>
+#include <memory>
+#include <stdexcept>
+
+#include <folly/Executor.h>
+#include <folly/portability/BitsFunctexcept.h>
+
+namespace folly {
+  // An executor that supports timed scheduling. Like RxScheduler.
+  class ScheduledExecutor : public virtual Executor {
+   public:
+     // Reality is that better than millisecond resolution is very hard to
+     // achieve. However, we reserve the right to be incredible.
+     typedef std::chrono::microseconds Duration;
+     typedef std::chrono::steady_clock::time_point TimePoint;
+
+     ~ScheduledExecutor() override = default;
+
+     void add(Func) override = 0;
+
+     /// Alias for add() (for Rx consistency)
+     void schedule(Func&& a) { add(std::move(a)); }
+
+     /// Schedule a Func to be executed after dur time has elapsed
+     /// Expect millisecond resolution at best.
+     void schedule(Func&& a, Duration const& dur) {
+       scheduleAt(std::move(a), now() + dur);
+     }
+
+     /// Schedule a Func to be executed at time t, or as soon afterward as
+     /// possible. Expect millisecond resolution at best. Must be threadsafe.
+     virtual void scheduleAt(Func&& /* a */, TimePoint const& /* t */) {
+       std::__throw_logic_error("unimplemented");
+     }
+
+     /// Get this executor's notion of time. Must be threadsafe.
+     virtual TimePoint now() {
+       return std::chrono::steady_clock::now();
+     }
+  };
+}
index 373e4ac..a45de25 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <folly/LifoSem.h>
 #include <folly/executors/DrivableExecutor.h>
-#include <folly/futures/ScheduledExecutor.h>
+#include <folly/executors/ScheduledExecutor.h>
 
 namespace folly {
   /// A ManualExecutor only does work when you turn the crank, by calling
index e4bce67..b839056 100644 (file)
@@ -730,7 +730,7 @@ Although inspired by the C++11 std::future interface, it is not a drop-in replac
 <li><a href="https://github.com/facebook/folly/blob/master/folly/futures/ManualExecutor.h" target="_blank">ManualExecutor</a> only executes work when manually cranked. This is useful for testing.</li>
 <li><a href="https://github.com/facebook/folly/blob/master/folly/futures/InlineExecutor.h" target="_blank">InlineExecutor</a> executes work immediately inline</li>
 <li><a href="https://github.com/facebook/folly/blob/master/folly/futures/QueuedImmediateExecutor.h" target="_blank">QueuedImmediateExecutor</a> is similar to InlineExecutor, but work added during callback execution will be queued instead of immediately executed</li>
-<li><a href="https://github.com/facebook/folly/blob/master/folly/futures/ScheduledExecutor.h" target="_blank">ScheduledExecutor</a> is a subinterface of Executor that supports scheduled (i.e. delayed) execution. There aren&#039;t many implementations yet, see <a class="remarkup-task" href="#" target="_blank">T5924392</a></li>
+<li><a href="https://github.com/facebook/folly/blob/master/folly/executors/ScheduledExecutor.h" target="_blank">ScheduledExecutor</a> is a subinterface of Executor that supports scheduled (i.e. delayed) execution. There aren&#039;t many implementations yet, see <a class="remarkup-task" href="#" target="_blank">T5924392</a></li>
 <li>Thrift&#039;s <a href="https://github.com/facebook/fbthrift/blob/master/thrift/lib/cpp/concurrency/ThreadManager.h" target="_blank">ThreadManager</a> is an Executor but we aim to deprecate it in favor of the aforementioned CPUThreadPoolExecutor</li>
 <li><a href="https://github.com/facebook/folly/blob/master/folly/executors/FutureExecutor.h" target="_blank">FutureExecutor</a> wraps another Executor and provides <tt>Future&lt;T&gt; addFuture(F func)</tt> which returns a Future representing the result of func. This is equivalent to <tt>futures::async(executor, func)</tt> and the latter should probably be preferred.</li>
 </ul></section><section class="dex_document"><h1>Timeouts and related features</h1><p class="dex_introduction">Futures provide a number of timing-related features. Here's an overview.</p><h2 id="timing-implementation">Timing implementation <a href="#timing-implementation" class="headerLink">#</a></h2>
diff --git a/folly/futures/ScheduledExecutor.h b/folly/futures/ScheduledExecutor.h
deleted file mode 100644 (file)
index ac77de9..0000000
+++ /dev/null
@@ -1,59 +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 <chrono>
-#include <memory>
-#include <stdexcept>
-
-#include <folly/Executor.h>
-#include <folly/portability/BitsFunctexcept.h>
-
-namespace folly {
-  // An executor that supports timed scheduling. Like RxScheduler.
-  class ScheduledExecutor : public virtual Executor {
-   public:
-     // Reality is that better than millisecond resolution is very hard to
-     // achieve. However, we reserve the right to be incredible.
-     typedef std::chrono::microseconds Duration;
-     typedef std::chrono::steady_clock::time_point TimePoint;
-
-     ~ScheduledExecutor() override = default;
-
-     void add(Func) override = 0;
-
-     /// Alias for add() (for Rx consistency)
-     void schedule(Func&& a) { add(std::move(a)); }
-
-     /// Schedule a Func to be executed after dur time has elapsed
-     /// Expect millisecond resolution at best.
-     void schedule(Func&& a, Duration const& dur) {
-       scheduleAt(std::move(a), now() + dur);
-     }
-
-     /// Schedule a Func to be executed at time t, or as soon afterward as
-     /// possible. Expect millisecond resolution at best. Must be threadsafe.
-     virtual void scheduleAt(Func&& /* a */, TimePoint const& /* t */) {
-       std::__throw_logic_error("unimplemented");
-     }
-
-     /// Get this executor's notion of time. Must be threadsafe.
-     virtual TimePoint now() {
-       return std::chrono::steady_clock::now();
-     }
-  };
-}