executors/NotificationQueueExecutor.h \
executors/PriorityLifoSemMPMCQueue.h \
executors/PriorityThreadFactory.h \
+ executors/ScheduledExecutor.h \
executors/SerialExecutor.h \
executors/ThreadFactory.h \
executors/ThreadPoolExecutor.h \
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 \
--- /dev/null
+/*
+ * 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();
+ }
+ };
+}
#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
<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'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't many implementations yet, see <a class="remarkup-task" href="#" target="_blank">T5924392</a></li>
<li>Thrift'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<T> 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>
+++ /dev/null
-/*
- * 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();
- }
- };
-}