Skip to content

Commit

Permalink
refactor: Use KeepAlive instead of Executor* (#109)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #109

X-link: facebookincubator/velox#11732

folly::Executor::KeepAlive is the recommended way of holding
references to executors as they ensure they are actually kept alive (block the
executor destructor). A shared_ptr or a naked pointer won't ensure the executor
is still available. Other functions from folly (like global pools) only provide
KeepAlive APIs.

Reviewed By: xiaoxmeng, sdruzkin

Differential Revision: D66724539

fbshipit-source-id: 231527346bdd09cac45293379c7454ac1595f31d
  • Loading branch information
pedroerp authored and facebook-github-bot committed Dec 5, 2024
1 parent acdae5a commit 0e6d7b6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions dwio/nimble/tablet/tests/TabletTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ TEST(TabletTests, OptionalSections) {

tabletWriter.close();

folly::CPUThreadPoolExecutor executor{5};
auto executor = std::make_shared<folly::CPUThreadPoolExecutor>(5);
facebook::velox::dwio::common::ExecutorBarrier barrier{executor};

for (auto useChaniedBuffers : {false, true}) {
Expand Down Expand Up @@ -914,7 +914,7 @@ TEST(TabletTests, ReferenceCountedCacheStressParallelDuplicates) {
++counter;
return std::make_shared<int>(id);
}};
folly::CPUThreadPoolExecutor executor(10);
auto executor = std::make_shared<folly::CPUThreadPoolExecutor>(10);
velox::dwio::common::ExecutorBarrier barrier(executor);
constexpr int kEntryIds = 100;
constexpr int kEntryDuplicates = 10;
Expand All @@ -937,7 +937,7 @@ TEST(TabletTests, ReferenceCountedCacheStressParallelDuplicatesSaveEntries) {
return std::make_shared<int>(id);
}};
folly::Synchronized<std::vector<std::shared_ptr<int>>> entries;
folly::CPUThreadPoolExecutor executor(10);
auto executor = std::make_shared<folly::CPUThreadPoolExecutor>(10);
velox::dwio::common::ExecutorBarrier barrier(executor);
constexpr int kEntryIds = 100;
constexpr int kEntryDuplicates = 10;
Expand All @@ -960,7 +960,7 @@ TEST(TabletTests, ReferenceCountedCacheStress) {
++counter;
return std::make_shared<int>(id);
}};
folly::CPUThreadPoolExecutor executor(10);
auto executor = std::make_shared<folly::CPUThreadPoolExecutor>(10);
velox::dwio::common::ExecutorBarrier barrier(executor);
constexpr int kEntryIds = 100;
constexpr int kEntryDuplicates = 10;
Expand All @@ -982,7 +982,7 @@ TEST(TabletTests, ReferenceCountedCacheStressSaveEntries) {
return std::make_shared<int>(id);
}};
folly::Synchronized<std::vector<std::shared_ptr<int>>> entries;
folly::CPUThreadPoolExecutor executor(10);
auto executor = std::make_shared<folly::CPUThreadPoolExecutor>(10);
velox::dwio::common::ExecutorBarrier barrier(executor);
constexpr int kEntryIds = 100;
constexpr int kEntryDuplicates = 10;
Expand Down

0 comments on commit 0e6d7b6

Please sign in to comment.