diff --git a/extension/threadpool/threadpool.cpp b/extension/threadpool/threadpool.cpp index e244954de6e..26acc9fb81b 100644 --- a/extension/threadpool/threadpool.cpp +++ b/extension/threadpool/threadpool.cpp @@ -75,6 +75,12 @@ bool ThreadPool::_unsafe_reset_threadpool(uint32_t new_thread_count) { return true; } +void ThreadPool::_unsafe_destroy_threadpool() { + std::lock_guard lock{mutex_}; + ET_LOG(Info, "Destroying threadpool."); + threadpool_.reset(); +} + void ThreadPool::run( runtime::FunctionRef fn, const size_t range) { diff --git a/extension/threadpool/threadpool.h b/extension/threadpool/threadpool.h index b4fe7e4be96..43957473a26 100644 --- a/extension/threadpool/threadpool.h +++ b/extension/threadpool/threadpool.h @@ -69,6 +69,15 @@ class ThreadPool final { "This API is experimental and may change without notice. Consider using UseNThreadsThreadPoolGuard")]] bool _unsafe_reset_threadpool(uint32_t num_threads); + /** + * INTERNAL: Destroys the threadpool. This is not a thread safe call. When calling this method, + * threads of the threadpool might be doing some work. Some other code may + * also be holding on to the threadpool pointer, that is no longer valid. + */ + [[deprecated( + "This API is experimental and may change without notice.")]] + void _unsafe_destroy_threadpool(); + /** * Run, in parallel, function fn(task_id) over task_id in range [0, range). * This function is blocking. All input is processed by the time it returns.