Apply clang-format to folly/fibers/
authorYedidya Feldblum <yfeldblum@fb.com>
Thu, 8 Jun 2017 22:26:53 +0000 (15:26 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 8 Jun 2017 22:37:10 +0000 (15:37 -0700)
Summary:
[Folly] Apply `clang-format` to `folly/fibers/`

With some manual rearrangement in the places where `clang-format` does awkward things, with the result that `clang-format` over `folly/fibers/` becomes a no-op.

Reviewed By: igorsugak

Differential Revision: D5178118

fbshipit-source-id: ae65ff1902666ba9106e18f916bb1d10e6406bf4

folly/fibers/AddTasks.h
folly/fibers/Baton.h
folly/fibers/EventBaseLoopController.h
folly/fibers/FiberManager.cpp
folly/fibers/FiberManager.h
folly/fibers/FiberManagerInternal-inl.h
folly/fibers/Promise.h
folly/fibers/test/FibersTest.cpp

index d0320becd31779dc9727e3eb435a24e6e94e37ae..936ed221a397efa47e4dcb6a6f550fa7a32281eb 100644 (file)
@@ -19,9 +19,9 @@
 #include <vector>
 
 #include <folly/Optional.h>
+#include <folly/Try.h>
 #include <folly/fibers/FiberManagerInternal.h>
 #include <folly/fibers/Promise.h>
-#include <folly/Try.h>
 
 namespace folly {
 namespace fibers {
index 36070ce78eb8ff87b18ba3fd7403f4f9b3c9aeca..9fd8c324bfcb9dc5e880367b6337ee13cf289af3 100644 (file)
@@ -154,7 +154,7 @@ class Baton {
     PreBlockAttempts = 300,
   };
 
-  explicit Baton(intptr_t state) : waitingFiber_(state){}
+  explicit Baton(intptr_t state) : waitingFiber_(state) {}
 
   void postHelper(intptr_t new_value);
   void postThread();
index 329997d238dd7b90f005344c9b3623e262e7fdc1..cab36c0cee1c1738c0591c175a9498800c896a83 100644 (file)
@@ -107,7 +107,6 @@ class EventBaseLoopController : public LoopController {
 
   friend class FiberManager;
 };
-
 }
 } // folly::fibers
 
index 054ed1713a6433961522504f7a4ab74211a0c9e1..9a3d2446b897ae810af925573865d751463ed0c5 100644 (file)
@@ -254,8 +254,9 @@ static AsanStartSwitchStackFuncPtr getStartSwitchStackFunc() {
   }
 
   // Check whether we can find a dynamically linked enter function
-  if (nullptr != (fn = (AsanStartSwitchStackFuncPtr)dlsym(
-                      RTLD_DEFAULT, "__sanitizer_start_switch_fiber"))) {
+  if (nullptr !=
+      (fn = (AsanStartSwitchStackFuncPtr)dlsym(
+           RTLD_DEFAULT, "__sanitizer_start_switch_fiber"))) {
     return fn;
   }
 
@@ -272,8 +273,9 @@ static AsanFinishSwitchStackFuncPtr getFinishSwitchStackFunc() {
   }
 
   // Check whether we can find a dynamically linked exit function
-  if (nullptr != (fn = (AsanFinishSwitchStackFuncPtr)dlsym(
-                      RTLD_DEFAULT, "__sanitizer_finish_switch_fiber"))) {
+  if (nullptr !=
+      (fn = (AsanFinishSwitchStackFuncPtr)dlsym(
+           RTLD_DEFAULT, "__sanitizer_finish_switch_fiber"))) {
     return fn;
   }
 
@@ -290,8 +292,9 @@ static AsanUnpoisonMemoryRegionFuncPtr getUnpoisonMemoryRegionFunc() {
   }
 
   // Check whether we can find a dynamically linked unpoison function
-  if (nullptr != (fn = (AsanUnpoisonMemoryRegionFuncPtr)dlsym(
-                      RTLD_DEFAULT, "__asan_unpoison_memory_region"))) {
+  if (nullptr !=
+      (fn = (AsanUnpoisonMemoryRegionFuncPtr)dlsym(
+           RTLD_DEFAULT, "__asan_unpoison_memory_region"))) {
     return fn;
   }
 
index 9e1fa067454f7afbf48b0d395a86790c4009d896..7aff3cd3e868ee8d7377b551e90ea699ce516423 100644 (file)
@@ -16,4 +16,5 @@
 #pragma once
 
 #include <folly/fibers/FiberManagerInternal.h>
+
 #include <folly/fibers/FiberManager-inl.h>
index 862e6a30099e88713ff4dd8d0d5928337b073d08..8e343b318ca7f0f7acb002cc11505cfb8e572593 100644 (file)
 #ifdef __APPLE__
 #include <folly/ThreadLocal.h>
 #endif
+#include <folly/Try.h>
 #include <folly/fibers/Baton.h>
 #include <folly/fibers/Fiber.h>
 #include <folly/fibers/LoopController.h>
 #include <folly/fibers/Promise.h>
-#include <folly/Try.h>
 
 namespace folly {
 namespace fibers {
index 40fda3dcbcea30fc737933f1b19531ac06cc723a..f42d62d1504f5c3b9fdee4fbc60f1c813693e95c 100644 (file)
@@ -15,8 +15,8 @@
  */
 #pragma once
 
-#include <folly/fibers/traits.h>
 #include <folly/Try.h>
+#include <folly/fibers/traits.h>
 
 namespace folly {
 namespace fibers {
index 733ba7c2758ef1842f11ec78607efa7f0cddad6c..9717ddaab7671fd7abcf5dc6d04aaa57fa96f0c0 100644 (file)
@@ -330,21 +330,20 @@ TEST(FiberManager, awaitThrow) {
   getFiberManager(evb)
       .addTaskFuture([&] {
         EXPECT_THROW(
-          await([](Promise<int> p) {
+            await([](Promise<int> p) {
               p.setValue(42);
               throw ExpectedException();
             }),
-          ExpectedException
-        );
+            ExpectedException);
 
         EXPECT_THROW(
-          await([&](Promise<int> p) {
+            await([&](Promise<int> p) {
               evb.runInEventBaseThread([p = std::move(p)]() mutable {
-                  p.setValue(42);
-                });
+                p.setValue(42);
+              });
               throw ExpectedException();
             }),
-          ExpectedException);
+            ExpectedException);
       })
       .waitVia(&evb);
 }
@@ -1649,20 +1648,20 @@ folly::Future<std::vector<std::string>> doubleBatchInnerDispatch(
       std::vector<int>,
       std::vector<std::string>,
       ExecutorT>
-  batchDispatcher(executor, [=](std::vector<std::vector<int>>&& batch) {
-    std::vector<std::vector<std::string>> results;
-    int numberOfElements = 0;
-    for (auto& unit : batch) {
-      numberOfElements += unit.size();
-      std::vector<std::string> result;
-      for (auto& element : unit) {
-        result.push_back(folly::to<std::string>(element));
-      }
-      results.push_back(std::move(result));
-    }
-    EXPECT_EQ(totalNumberOfElements, numberOfElements);
-    return results;
-  });
+      batchDispatcher(executor, [=](std::vector<std::vector<int>>&& batch) {
+        std::vector<std::vector<std::string>> results;
+        int numberOfElements = 0;
+        for (auto& unit : batch) {
+          numberOfElements += unit.size();
+          std::vector<std::string> result;
+          for (auto& element : unit) {
+            result.push_back(folly::to<std::string>(element));
+          }
+          results.push_back(std::move(result));
+        }
+        EXPECT_EQ(totalNumberOfElements, numberOfElements);
+        return results;
+      });
 
   return batchDispatcher.add(std::move(input));
 }
@@ -1675,38 +1674,39 @@ void doubleBatchOuterDispatch(
     ExecutorT& executor,
     int totalNumberOfElements,
     int index) {
-  thread_local BatchDispatcher<int, std::string, ExecutorT>
-  batchDispatcher(executor, [=, &executor](std::vector<int>&& batch) {
-    EXPECT_EQ(totalNumberOfElements, batch.size());
-    std::vector<std::string> results;
-    std::vector<folly::Future<std::vector<std::string>>>
-        innerDispatchResultFutures;
-
-    std::vector<int> group;
-    for (auto unit : batch) {
-      group.push_back(unit);
-      if (group.size() == 5) {
-        auto localGroup = group;
-        group.clear();
-
-        innerDispatchResultFutures.push_back(doubleBatchInnerDispatch(
-            executor, totalNumberOfElements, localGroup));
-      }
-    }
-
-    folly::collectAll(
-        innerDispatchResultFutures.begin(), innerDispatchResultFutures.end())
-        .then([&](
-            std::vector<Try<std::vector<std::string>>> innerDispatchResults) {
-          for (auto& unit : innerDispatchResults) {
-            for (auto& element : unit.value()) {
-              results.push_back(element);
-            }
+  thread_local BatchDispatcher<int, std::string, ExecutorT> batchDispatcher(
+      executor, [=, &executor](std::vector<int>&& batch) {
+        EXPECT_EQ(totalNumberOfElements, batch.size());
+        std::vector<std::string> results;
+        std::vector<folly::Future<std::vector<std::string>>>
+            innerDispatchResultFutures;
+
+        std::vector<int> group;
+        for (auto unit : batch) {
+          group.push_back(unit);
+          if (group.size() == 5) {
+            auto localGroup = group;
+            group.clear();
+
+            innerDispatchResultFutures.push_back(doubleBatchInnerDispatch(
+                executor, totalNumberOfElements, localGroup));
           }
-        })
-        .get();
-    return results;
-  });
+        }
+
+        folly::collectAll(
+            innerDispatchResultFutures.begin(),
+            innerDispatchResultFutures.end())
+            .then([&](std::vector<Try<std::vector<std::string>>>
+                          innerDispatchResults) {
+              for (auto& unit : innerDispatchResults) {
+                for (auto& element : unit.value()) {
+                  results.push_back(element);
+                }
+              }
+            })
+            .get();
+        return results;
+      });
 
   auto indexCopy = index;
   auto result = batchDispatcher.add(std::move(indexCopy));
@@ -2139,7 +2139,7 @@ TEST(TimedMutex, ThreadFiberDeadlockRace) {
  */
 #ifndef FOLLY_SANITIZE_ADDRESS
 TEST(FiberManager, recordStack) {
-  std::thread([] {
+  auto f = [] {
     folly::fibers::FiberManager::Options opts;
     opts.recordStackEvery = 1;
 
@@ -2165,6 +2165,7 @@ TEST(FiberManager, recordStack) {
 
     // Check that we properly accounted fiber stack usage.
     EXPECT_LT(n * sizeof(int), fm.stackHighWatermark());
-  }).join();
+  };
+  std::thread(f).join();
 }
 #endif