move wangle/Executor.h to folly/ root
authorJames Sedgwick <jsedgwick@fb.com>
Mon, 15 Dec 2014 19:43:32 +0000 (11:43 -0800)
committerJoelMarcey <joelm@fb.com>
Thu, 18 Dec 2014 20:29:40 +0000 (12:29 -0800)
Summary:
this removes the dep EventBase has on wangle as we prepare to split off wangle
also changes namespace from folly::wangle to folly

Test Plan: just a couple of codemods so waiting for contbuild

Reviewed By: davejwatson@fb.com

Subscribers: trunkagent, fbcode-common-diffs@, chaoyc, search-fbcode-diffs@, zeus-diffs@, nli, cold-storage-diffs@, unicorn-diffs@, targeting-diff-backend@, hannesr, vighnesh, fugalh, alandau, bmatheny, adityab, zhuohuang, luk, darshan, gunjan, hdoshi, dzhulgakov, alihussains, panin, ves, mshneer, folly-diffs@, lins, nimishshah

FB internal diff: D1737376

Tasks: 5802833

Signature: t1:1737376:1418423430:82d219c34fcc50218c380a17435e5880e53db6bd

19 files changed:
folly/Executor.h [new file with mode: 0644]
folly/Makefile.am
folly/experimental/wangle/bootstrap/ServerBootstrap-inl.h
folly/experimental/wangle/bootstrap/ServerBootstrap.cpp
folly/experimental/wangle/concurrent/ThreadFactory.h
folly/experimental/wangle/concurrent/ThreadPoolExecutor.h
folly/experimental/wangle/concurrent/test/ThreadPoolExecutorTest.cpp
folly/experimental/wangle/rx/Observable.h
folly/experimental/wangle/rx/types.h
folly/io/async/EventBase.h
folly/wangle/Executor.h [deleted file]
folly/wangle/InlineExecutor.h
folly/wangle/QueuedImmediateExecutor.h
folly/wangle/ScheduledExecutor.h
folly/wangle/detail/Core.h
folly/wangle/test/FutureTest.cpp
folly/wangle/test/Thens.cpp
folly/wangle/test/Thens.h
folly/wangle/test/thens.rb

diff --git a/folly/Executor.h b/folly/Executor.h
new file mode 100644 (file)
index 0000000..5ba4844
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2014 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 <functional>
+
+namespace folly {
+
+typedef std::function<void()> Func;
+
+/// An Executor accepts units of work with add(), which should be
+/// threadsafe.
+class Executor {
+ public:
+  virtual ~Executor() = default;
+
+  /// Enqueue a function to executed by this executor. This and all
+  /// variants must be threadsafe.
+  virtual void add(Func) = 0;
+
+  /// A convenience function for shared_ptr to legacy functors.
+  ///
+  /// Sometimes you have a functor that is move-only, and therefore can't be
+  /// converted to a std::function (e.g. std::packaged_task). In that case,
+  /// wrap it in a shared_ptr (or maybe folly::MoveWrapper) and use this.
+  template <class P>
+  void addPtr(P fn) {
+    this->add([fn]() mutable { (*fn)(); });
+  }
+};
+
+} // folly
index 4f2d8da708daeedf817edebb93b862bb44944b98..7f78fa6610a114c3050886fb20e54890ab34680a 100644 (file)
@@ -65,6 +65,7 @@ nobase_follyinclude_HEADERS = \
        dynamic-inl.h \
        Exception.h \
        ExceptionWrapper.h \
+       Executor.h \
        EvictingCacheMap.h \
        experimental/Bits.h \
        experimental/EliasFanoCoding.h \
@@ -235,7 +236,6 @@ nobase_follyinclude_HEADERS = \
        Varint.h \
        VersionCheck.h \
        wangle/Deprecated.h \
-       wangle/Executor.h \
        wangle/Future-inl.h \
        wangle/Future.h \
        wangle/InlineExecutor.h \
index 7268e2a7ddb131c7a9f01261e46b8baddccd8a46..8db45409221913736ae2a3f55cb3798cd16bd69d 100644 (file)
@@ -105,7 +105,7 @@ class ServerWorkerFactory : public folly::wangle::ThreadFactory {
         std::make_shared<folly::wangle::NamedThreadFactory>("BootstrapWorker"))
       , acceptorFactory_(acceptorFactory)
     {}
-  virtual std::thread newThread(folly::wangle::Func&& func) override;
+  virtual std::thread newThread(folly::Func&& func) override;
 
   void setInternalFactory(
     std::shared_ptr<folly::wangle::NamedThreadFactory> internalFactory);
index 594e960467e6ef57781462f3d7652e26e288b3e6..7a75452bc4bca82c8ccaebfee69d7caaf06d247b 100644 (file)
@@ -20,7 +20,7 @@
 namespace folly {
 
 std::thread ServerWorkerFactory::newThread(
-    folly::wangle::Func&& func) {
+    folly::Func&& func) {
   auto id = nextWorkerId_++;
   auto worker = acceptorFactory_->newAcceptor();
   {
index 8f799065bbcaded3a3ba0a4104049a99642f7a12..7654fbc9da78d690758ab80158b0623c8f830220 100644 (file)
@@ -15,7 +15,7 @@
  */
 
 #pragma once
-#include <folly/wangle/Executor.h>
+#include <folly/Executor.h>
 
 #include <thread>
 
index b6b0dd788b7b7c019012fba321e8dc542a0e829d..451f164f54497d2f528a3e7b45b3f84269b0398b 100644 (file)
@@ -15,7 +15,7 @@
  */
 
 #pragma once
-#include <folly/wangle/Executor.h>
+#include <folly/Executor.h>
 #include <folly/experimental/wangle/concurrent/LifoSemMPMCQueue.h>
 #include <folly/experimental/wangle/concurrent/NamedThreadFactory.h>
 #include <folly/experimental/wangle/rx/Observable.h>
index 2749d0cd583ecdb971456e6b1af22537793ef27f..9898d40e68a405270650f13c90ba4a54d182b589 100644 (file)
@@ -24,7 +24,7 @@
 using namespace folly::wangle;
 using namespace std::chrono;
 
-static Func burnMs(uint64_t ms) {
+static folly::Func burnMs(uint64_t ms) {
   return [ms]() { std::this_thread::sleep_for(milliseconds(ms)); };
 }
 
index 7a914696ca19b4d73c2d872f3a66bca4064e31f9..e9a6196e4c5e03df6b8a5afba79a016485f086a8 100644 (file)
@@ -24,7 +24,7 @@
 #include <folly/SmallLocks.h>
 #include <folly/ThreadLocal.h>
 #include <folly/small_vector.h>
-#include <folly/wangle/Executor.h>
+#include <folly/Executor.h>
 #include <map>
 #include <memory>
 
index 0f10c1cb712496f529e8ba13d4f6d0d782defcbb..27c2f3b7440521cd323551c547a8e2117796e6a4 100644 (file)
 #pragma once
 
 #include <folly/ExceptionWrapper.h>
-#include <folly/wangle/Executor.h>
+#include <folly/Executor.h>
 
 namespace folly { namespace wangle {
   typedef folly::exception_wrapper Error;
-  // The wangle::Executor is basically an rx Scheduler (by design). So just
+  // The Executor is basically an rx Scheduler (by design). So just
   // alias it.
-  typedef std::shared_ptr<folly::wangle::Executor> SchedulerPtr;
+  typedef std::shared_ptr<folly::Executor> SchedulerPtr;
 
   template <class T, size_t InlineObservers = 3> struct Observable;
   template <class T> struct Observer;
index ec4a6ad653b62e681a0531c0085afa5ed9c76c9c..109da17cc5839c319ce3df3be1e305b1c07b6cb2 100644 (file)
@@ -20,7 +20,7 @@
 #include <folly/io/async/AsyncTimeout.h>
 #include <folly/io/async/TimeoutManager.h>
 #include <folly/io/async/Request.h>
-#include <folly/wangle/Executor.h>
+#include <folly/Executor.h>
 #include <memory>
 #include <stack>
 #include <list>
@@ -96,7 +96,7 @@ class RequestEventBase : public RequestData {
  * another thread it is explicitly listed in the method comments.
  */
 class EventBase :
-  private boost::noncopyable, public TimeoutManager, public wangle::Executor
+  private boost::noncopyable, public TimeoutManager, public Executor
 {
  public:
   /**
@@ -478,7 +478,7 @@ class EventBase :
    */
   const std::string& getName();
 
-  /// Implements the wangle::Executor interface
+  /// Implements the Executor interface
   void add(Cob fn) override {
     // runInEventBaseThread() takes a const&,
     // so no point in doing std::move here.
diff --git a/folly/wangle/Executor.h b/folly/wangle/Executor.h
deleted file mode 100644 (file)
index bd720f6..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2014 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 <functional>
-
-namespace folly { namespace wangle {
-
-typedef std::function<void()> Func;
-
-/// An Executor accepts units of work with add(), which should be
-/// threadsafe.
-class Executor {
- public:
-  virtual ~Executor() = default;
-
-  /// Enqueue a function to executed by this executor. This and all
-  /// variants must be threadsafe.
-  virtual void add(Func) = 0;
-
-  /// A convenience function for shared_ptr to legacy functors.
-  ///
-  /// Sometimes you have a functor that is move-only, and therefore can't be
-  /// converted to a std::function (e.g. std::packaged_task). In that case,
-  /// wrap it in a shared_ptr (or maybe folly::MoveWrapper) and use this.
-  template <class P>
-  void addPtr(P fn) {
-    this->add([fn]() mutable { (*fn)(); });
-  }
-};
-
-}} // folly::wangle
index df9bfe29144087e7c0b0fe406a82be89a76e2026..e6924085d933b685ec369a7e1457be8ec690350c 100644 (file)
@@ -15,7 +15,7 @@
  */
 
 #pragma once
-#include <folly/wangle/Executor.h>
+#include <folly/Executor.h>
 
 namespace folly { namespace wangle {
 
index a4c4985df215e9e182db8950b57acc92b14630fd..a82c32dbdb58b5d6c2bed19f79d2d0c57d2a5103 100644 (file)
@@ -16,7 +16,7 @@
 
 #pragma once
 
-#include <folly/wangle/Executor.h>
+#include <folly/Executor.h>
 
 namespace folly { namespace wangle {
 
index fe5f6f128a0abc9a8bb867cec3d7a380602a567a..94850c28782b30e856d558488df0629df7b88b09 100644 (file)
@@ -16,7 +16,7 @@
 
 #pragma once
 
-#include <folly/wangle/Executor.h>
+#include <folly/Executor.h>
 #include <chrono>
 #include <memory>
 #include <stdexcept>
index 03d09b747547041585a6868274c6f2aa666f8ce5..933cd7adf89d4453248e99351b388e8e5ccf2693 100644 (file)
@@ -27,7 +27,7 @@
 #include <folly/wangle/Try.h>
 #include <folly/wangle/Promise.h>
 #include <folly/wangle/Future.h>
-#include <folly/wangle/Executor.h>
+#include <folly/Executor.h>
 #include <folly/wangle/detail/FSM.h>
 
 #include <folly/io/async/Request.h>
index a068dc01c23f58973db19550a8db88b066d0bf9b..d6cfbfbca10d891f217c193d84f8e52502f0c14d 100644 (file)
@@ -24,7 +24,7 @@
 #include <type_traits>
 #include <unistd.h>
 #include <folly/Memory.h>
-#include <folly/wangle/Executor.h>
+#include <folly/Executor.h>
 #include <folly/wangle/Future.h>
 #include <folly/wangle/ManualExecutor.h>
 #include <folly/MPMCQueue.h>
index f990678d133c6e5ae8a6e13e87f99ae0eba425d7..e8ac875dae6c5812a7950002bcb09624e29229d1 100644 (file)
@@ -7,7 +7,7 @@
 
 TEST(Future, thenVariants) {
   SomeClass anObject;
-  Executor* anExecutor;
+  folly::Executor* anExecutor;
 
   {Future<B> f = someFuture<A>().then(&aFunction<Future<B>, Try<A>&&>);}
   {Future<B> f = someFuture<A>().then(&SomeClass::aStaticMethod<Future<B>, Try<A>&&>);}
index 995ff848694b4dac921fa870bd5867c676fcd4ec..928f8205ad9a89f70f388b27e923713b48f67f5b 100644 (file)
@@ -18,7 +18,7 @@
 #include <gtest/gtest.h>
 #include <memory>
 #include <folly/wangle/Future.h>
-#include <folly/wangle/Executor.h>
+#include <folly/Executor.h>
 
 using namespace folly::wangle;
 using namespace std;
index 9c7537255b9a19c7fc84cc7f0e9c6eff63074a93..61ca26de48ca5d64a0438d7077f1631c9f80f546 100755 (executable)
@@ -70,7 +70,7 @@ print <<EOF
 
 TEST(Future, thenVariants) {
   SomeClass anObject;
-  Executor* anExecutor;
+  folly::Executor* anExecutor;
 
   #{tests.join("\n  ")}
 }