Skip to content

Commit

Permalink
wait for thread pools to be idle on unload
Browse files Browse the repository at this point in the history
  • Loading branch information
paleolimbot committed Aug 2, 2022
1 parent 2a02757 commit d38781f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions r/R/arrow-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
invisible()
}

.onUnload <- function(...) {
WaitForIdleThreadPool()
}

configure_tzdb <- function() {
# This is needed on Windows to support timezone-aware calculations
if (requireNamespace("tzdb", quietly = TRUE)) {
Expand Down
4 changes: 4 additions & 0 deletions r/R/arrowExports.R

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions r/src/arrowExports.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions r/src/threadpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,17 @@ int GetIOThreadPoolCapacity() { return arrow::io::GetIOThreadPoolCapacity(); }
void SetIOThreadPoolCapacity(int threads) {
StopIfNotOk(arrow::io::SetIOThreadPoolCapacity(threads));
}

namespace arrow {
namespace io {
namespace internal {
arrow::internal::ThreadPool* GetIOThreadPool();
}
} // namespace io
} // namespace arrow

// [[arrow::export]]
void WaitForIdleThreadPool() {
arrow::internal::GetCpuThreadPool()->WaitForIdle();
arrow::io::internal::GetIOThreadPool()->WaitForIdle();
}

0 comments on commit d38781f

Please sign in to comment.