From 811c6c339d07e20c61ec9ce67f88bbf63459bfb5 Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Thu, 8 Jun 2017 15:26:53 -0700 Subject: [PATCH] Apply clang-format to folly/fibers/ 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 | 2 +- folly/fibers/Baton.h | 2 +- folly/fibers/EventBaseLoopController.h | 1 - folly/fibers/FiberManager.cpp | 15 ++-- folly/fibers/FiberManager.h | 1 + folly/fibers/FiberManagerInternal-inl.h | 2 +- folly/fibers/Promise.h | 2 +- folly/fibers/test/FibersTest.cpp | 109 ++++++++++++------------ 8 files changed, 69 insertions(+), 65 deletions(-) diff --git a/folly/fibers/AddTasks.h b/folly/fibers/AddTasks.h index d0320bec..936ed221 100644 --- a/folly/fibers/AddTasks.h +++ b/folly/fibers/AddTasks.h @@ -19,9 +19,9 @@ #include #include +#include #include #include -#include namespace folly { namespace fibers { diff --git a/folly/fibers/Baton.h b/folly/fibers/Baton.h index 36070ce7..9fd8c324 100644 --- a/folly/fibers/Baton.h +++ b/folly/fibers/Baton.h @@ -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(); diff --git a/folly/fibers/EventBaseLoopController.h b/folly/fibers/EventBaseLoopController.h index 329997d2..cab36c0c 100644 --- a/folly/fibers/EventBaseLoopController.h +++ b/folly/fibers/EventBaseLoopController.h @@ -107,7 +107,6 @@ class EventBaseLoopController : public LoopController { friend class FiberManager; }; - } } // folly::fibers diff --git a/folly/fibers/FiberManager.cpp b/folly/fibers/FiberManager.cpp index 054ed171..9a3d2446 100644 --- a/folly/fibers/FiberManager.cpp +++ b/folly/fibers/FiberManager.cpp @@ -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; } diff --git a/folly/fibers/FiberManager.h b/folly/fibers/FiberManager.h index 9e1fa067..7aff3cd3 100644 --- a/folly/fibers/FiberManager.h +++ b/folly/fibers/FiberManager.h @@ -16,4 +16,5 @@ #pragma once #include + #include diff --git a/folly/fibers/FiberManagerInternal-inl.h b/folly/fibers/FiberManagerInternal-inl.h index 862e6a30..8e343b31 100644 --- a/folly/fibers/FiberManagerInternal-inl.h +++ b/folly/fibers/FiberManagerInternal-inl.h @@ -25,11 +25,11 @@ #ifdef __APPLE__ #include #endif +#include #include #include #include #include -#include namespace folly { namespace fibers { diff --git a/folly/fibers/Promise.h b/folly/fibers/Promise.h index 40fda3dc..f42d62d1 100644 --- a/folly/fibers/Promise.h +++ b/folly/fibers/Promise.h @@ -15,8 +15,8 @@ */ #pragma once -#include #include +#include namespace folly { namespace fibers { diff --git a/folly/fibers/test/FibersTest.cpp b/folly/fibers/test/FibersTest.cpp index 733ba7c2..9717ddaa 100644 --- a/folly/fibers/test/FibersTest.cpp +++ b/folly/fibers/test/FibersTest.cpp @@ -330,21 +330,20 @@ TEST(FiberManager, awaitThrow) { getFiberManager(evb) .addTaskFuture([&] { EXPECT_THROW( - await([](Promise p) { + await([](Promise p) { p.setValue(42); throw ExpectedException(); }), - ExpectedException - ); + ExpectedException); EXPECT_THROW( - await([&](Promise p) { + await([&](Promise 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> doubleBatchInnerDispatch( std::vector, std::vector, ExecutorT> - batchDispatcher(executor, [=](std::vector>&& batch) { - std::vector> results; - int numberOfElements = 0; - for (auto& unit : batch) { - numberOfElements += unit.size(); - std::vector result; - for (auto& element : unit) { - result.push_back(folly::to(element)); - } - results.push_back(std::move(result)); - } - EXPECT_EQ(totalNumberOfElements, numberOfElements); - return results; - }); + batchDispatcher(executor, [=](std::vector>&& batch) { + std::vector> results; + int numberOfElements = 0; + for (auto& unit : batch) { + numberOfElements += unit.size(); + std::vector result; + for (auto& element : unit) { + result.push_back(folly::to(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 - batchDispatcher(executor, [=, &executor](std::vector&& batch) { - EXPECT_EQ(totalNumberOfElements, batch.size()); - std::vector results; - std::vector>> - innerDispatchResultFutures; - - std::vector 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>> innerDispatchResults) { - for (auto& unit : innerDispatchResults) { - for (auto& element : unit.value()) { - results.push_back(element); - } + thread_local BatchDispatcher batchDispatcher( + executor, [=, &executor](std::vector&& batch) { + EXPECT_EQ(totalNumberOfElements, batch.size()); + std::vector results; + std::vector>> + innerDispatchResultFutures; + + std::vector 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>> + 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 -- 2.34.1