Skip to content

Commit

Permalink
Minor tidy ups
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Newton committed Dec 4, 2024
1 parent d16f11f commit dbefb7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions cpp/src/arrow/filesystem/test_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -584,12 +584,14 @@ void GenericFileSystemTest::TestCopyFiles(FileSystem* fs) {
GTEST_SKIP() << "Filesystem have false positive memory leak with generator";
}
#endif
auto original_threads = fs->io_context().executor()->GetCapacity();
auto io_thread_pool =
static_cast<arrow::internal::ThreadPool*>(fs->io_context().executor());
auto original_threads = io_thread_pool->GetCapacity();
// Needs to be smaller than the number of files we test with to catch GH-15233
ASSERT_OK(io::SetIOThreadPoolCapacity(2));
ASSERT_OK(io_thread_pool->SetCapacity(2));
// Ensure the thread pool capacity is set back to the original value after the test
auto reset_thread_pool = [original_threads](void*) {
ASSERT_OK(io::SetIOThreadPoolCapacity(original_threads));
auto reset_thread_pool = [io_thread_pool, original_threads](void*) {
ASSERT_OK(io_thread_pool->SetCapacity(original_threads));
};
std::unique_ptr<void, decltype(reset_thread_pool)> resetThreadPoolGuard(
nullptr, reset_thread_pool);
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/util/thread_pool_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ TEST_F(TestThreadPool, TasksRunInPriorityOrder) {

ASSERT_OK(pool->Shutdown());

for (size_t i = 1; i < recorded_times.size(); ++i) {
for (size_t i = 1; i < kNumTasks; ++i) {
ASSERT_GE(recorded_times[i - 1], recorded_times[i]);
ASSERT_LT(futures[i - 1].result().ValueOrDie(), futures[i].result().ValueOrDie());
}
Expand All @@ -623,7 +623,7 @@ TEST_F(TestThreadPool, TasksOfEqualPriorityRunInSpawnOrder) {

ASSERT_OK(pool->Shutdown());

for (size_t i = 1; i < recorded_times.size(); ++i) {
for (size_t i = 1; i < kNumTasks; ++i) {
ASSERT_LE(recorded_times[i - 1], recorded_times[i]);
ASSERT_LT(futures[i - 1].result().ValueOrDie(), futures[i].result().ValueOrDie());
}
Expand Down

0 comments on commit dbefb7e

Please sign in to comment.